AtCoder Beginner Contest 053
A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n<1200) { cout<<"ABC"; } else { cout<<"ARC"; } return 0; }
|
B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include <iostream> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7;
bool is_prime(int n) { if (n == 1) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; }
vector<int> p;
int main() { string s; cin >> s; int j = -1; int k; for (int i = 0; i < s.length(); i++) { if (s[i] == 'A' && j==-1) { j = i; } if (s[i] == 'Z') { k = i; } } cout << k - j + 1 << '\n'; return 0; }
|
C
贪心:先6后5即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <iostream> #include <vector> using namespace std; typedef long long ll; const ll mod = 1e9 + 7;
bool is_prime(int n) { if (n == 1) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; }
vector<int> p;
int main() { ll x; cin >> x; ll ans = x / 11 * 2; ll sum = x % 11; if (sum > 6) { cout << ans + 2 << '\n'; } else if (sum > 0) { cout << ans + 1 << '\n'; } else { cout << ans << '\n'; } return 0; }
|
D
题目大意:
给你N个卡片,每次操作可以任意拿三个卡片出来,去掉最大值和最小值的卡片,中间值卡片放回去。
问最多可以剩余几张卡片,并且使得不重复。
其实转换一下题意,就是任意扔掉2个,然后就结束了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 2e5 + 10; const ll mod = 1e9 + 7; ll inv[maxn], fac[maxn];
map<ll, ll> f; ll cal(ll n) { if (f[n]) { return f[n]; } return f[n] = (cal(n / 2) + cal((n - 1) / 2) + cal((n - 2) / 2)) % mod; } const int N = 101; int g[N][N]; bool vis[N][N]; int main() { ll ans = 0; int n; cin >> n; map<int, int> mp; for (int i = 1; i <= n; i++) { int x; cin >> x; if (!mp[x]) { mp[x] = 1; } else { ans++; } } ans += ans & 1; cout <<n-ans << '\n'; return 0; }
|
PS:这一场也是很简单,
没什么好学的,最后一道题转换一下题意,每次拿两张,算出多余的。