A
200/8=25
B
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = l; i <= r; ++i) using namespace std; typedef long long ll; const int N = 1e6 + 7; bool isPrime(int n) { for (int i = 2, x = sqrt(n); i <= x; ++i) { if (n % i == 0) return 0; } return 1; } bool ok(int n) { while (n) { if (n % 10 != 2 and n % 10 != 3 and n % 10 != 5 and n % 10 != 7) { return 0; } n /= 10; } return 1; } int main() { int cnt = 0; rep(i, 2, 20210605) if (ok(i) and isPrime(i))++ cnt; printf("%d\n", cnt); // 1903 return 0; }
C
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = l; i <= r; ++i) typedef long long ll; using namespace std; const int N = 5e5 + 7; int nextDay(int n) { int y = n / 10000; int d = n % 100; int m = n / 100 % 100; if (m == 12 and d == 31) y += 1, m = 1, d = 1; else if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) { if (d == 31) m += 1, d = 1; else ++d; } else if (m == 2) { if (y % 4 == 0) { if (d == 29) m += 1, d = 1; else d += 1; } else { if (d == 28) m += 1, d = 1; else d += 1; } } else { if (d == 30) m += 1, d = 1; else d += 1; } return y * 10000 + m * 100 + d; } bool chk(int n) { int res = 0; while (n) { res += n % 10; n /= 10; } int t = sqrt(n); return res == t * t; } int main() { int cnt = 0; for (int i = 20010101; i <= 20211231; i = nextDay(i)) if (chk(i)) ++cnt; cout << cnt << endl; // 977 return 0; }
D
E
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = l; i <= r; ++i) using namespace std; typedef long long ll; const int N = 1e6 + 7; int main() { string s; cin >> s; for (char &c : s) if (islower(c)) c += 'A' - 'a'; cout << s; return 0; }
F
G
#include <bits/stdc++.h> #define rep(i, l, r) for (int i = l; i <= r; ++i) using namespace std; typedef long long ll; ll f[65][55]; int num[65], k; ll dfs(int len, int cnt, bool limit) { if (!len) return cnt == k; // 到达终态,判断 if (cnt > k) return 0; // 剪枝 if (!limit && ~f[len][cnt]) return f[len][cnt]; // 如果未达到终态,且已计算过,即可复用 ll &x = f[len][cnt], ans(0); int ed = limit ? num[len] : 1; // 边界 for (int i = 0; i <= ed; ++i) { ans += dfs(len - 1, cnt + (i == 1), limit && i == ed); } if (!limit) x = ans; // 记录复用 return ans; } int main() { int len(0); ll n; scanf("%lld%d", &n, &k); memset(f, -1, sizeof f); while (n) { num[++len] = n & 1; n >>= 1; } cout << dfs(len, 0, true) << '\n'; return 0; }