第一次参加 AtCoder 的比赛,感觉还挺简单。
比赛链接:https://atcoder.jp/contests/abc189
A - Slot
// Author : RioTian// Time : 21/01/23#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1e5 + 10;int main() {// freopen("in.txt","r",stdin);ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);string s;cin >> s;if (s[0] == s[1] && s[1] == s[2])cout << "Won\n";elsecout << "Lost\n";}
B - Alcoholic
高桥(大家都喜欢的高桥同学)要喝酒了,现在有n中酒,如果高桥同学喝酒的量大于 则会喝酒离开酒席。那么请输出高桥是在第几个酒上喝醉了,如果没有喝醉请输出 -1
// Author : RioTian// Time : 21/01/24#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1e5 + 10;int main() {// freopen("in.txt","r",stdin);ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);int n, v, p, x;int sum = 0;cin >> n >> x;for (int i = 1; i <= n; ++i) {cin >> v >> p;sum += v * p;if (sum > x * 100) {cout << i << endl;return 0;}}cout << -1 << endl;}
C - Mandarin
求最大连续序列和,但由于n比较小直接暴力即可。
// Author : RioTian// Time : 21/01/24#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 1e5 + 10;int a[N];int main() {// freopen("in.txt","r",stdin);ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);int n;cin >> n;for (int i = 0; i < n; ++i) cin >> a[i];int ans = 0;for (int l = 0; l < n; ++l) {int x = a[l];for (int r = l; r < n; ++r) {x = min(x, a[r]);ans = max(ans, x * (r - l + 1));}}cout << ans << endl;}
D - Logical Expression
如果 是
AND 则 opt 设为 true,在之后只要 %20%3D%20f(S1%2C…%2CS%7BN-1%7D)#card=math&code=f%28S1%2C…%2CS_N%29%20%3D%20f%28S_1%2C…%2CS%7BN-1%7D%29)
如歌 是
OR 则 opt 设为 false,需要 %20%3D%202%5EN%20%2B%20f(S1%2C…%2CS%7BN-1%7D)#card=math&code=f%28S1%2C…%2CS_N%29%20%3D%202%5EN%20%2B%20f%28S_1%2C…%2CS%7BN-1%7D%29)
// Author : RioTian// Time : 21/01/24#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N = 100;ll dp[N][2];bool opt[N];string s;int main() {// freopen("in.txt","r",stdin);ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);int n;cin >> n;for (int i = 0; i < n; ++i) {cin >> s;if (s[0] == 'A')opt[i] = true;elseopt[i] = false;}dp[0][0] = dp[0][1] = 1;for (int i = 1; i <= n; ++i) {if (opt[i - 1]) {dp[i][0] = 2 * dp[i - 1][0] + dp[i - 1][1];dp[i][1] = dp[i - 1][1];} else {dp[i][0] = dp[i - 1][0];dp[i][1] = 2 * dp[i - 1][1] + dp[i - 1][0];}}cout << dp[n][1] << endl;}
E,F比赛时没做就先鸽一下了
