#include<cstdio> #include<cstring> const int MAX_N = 20210605; int num[MAX_N +
1]; int sum = 0; void solve(int x) { int isPrime = 1; while(x > 0) { int b = x%
10; //b为x的个位数字 if(!(b == 2 || b == 3 || b == 5 || b == 7)) { isPrime = 0; break;
} x = x/10; } if(isPrime) sum++; } int main() { memset(num, 1, sizeof(num)); for
(int i = 2; i < 20210605; i++) { for(int j = 2; i*j <= 20210605; j++) { num[i*j]
= 0; } } for(int i = 1; i <= 20210605; i++) { if(num[i]) solve(i); } printf(
"%d\n", sum); return 0; }

#include<cstdio> #include<iostream> #include<string> using namespace std; int
res= 0; void solve(int x) { for(int i = 0; i < 100; i++) { if(i * i == x) res++;
} } int main() { string line; while(getline(cin, line)) { int len = line.length(
); int sum = 0; for(int i = 0; i < len; i++) { if(isdigit(line[i])) sum += line[
i] - '0'; } solve(sum); cout << res << endl; } }

#include<iostream> using namespace std; const int MAX_N = 2021;
//结点个数,用完全二叉树的编号代表结点 long long C(long long x) { if(x > MAX_N) return 0; return 1
+ C(2*x) + C(2*x+1); } long long W(long long x) { if(x > MAX_N) return 0; return
1 + 2*W(2*x) + 3*W(2*x+1) + C(2*x)*C(2*x)*C(2*x+1); } int main() { cout << W(1)
<< endl; return 0; }

#include<cstdio> #include<cstring> #include<ctype.h> char s[110]; int main() {
scanf("%s", s); for(int i = 0; i < strlen(s); i++) printf("%c", toupper(s[i]));
return 0; }

#include<cstdio> const int MAX_N = 200000000; int a[MAX_N], sum = 0; void solve
() { int maxn = 1, n = 1; for(int i = 1; i < MAX_N; i++) { a[i] = n++; if(n >
maxn) { maxn++; n=1; } } } int main() { solve(); int T; scanf("%d", &T); for(int
i= 0; i < T; i++) { int l, r; sum = 0; scanf("%d%d", &l, &r); for(int i = 0; l+
i<= r; i++) { sum += a[l+i]; } printf("%d\n", sum); } return 0; }

#include<cstdio> #include<cstring> const int MAX_N = 200000000; char s[MAX_N];
char s2[MAX_N]; int n, t; void reverse() { s2[0] = s[0]; for(int i = 1; i < n; i
++) { s2[i] = (s[i] - '0') ^ (s[i-1] - '0') + '0'; } strncpy(s, s2, n); } int
main() { scanf("%d%d", &n, &t); scanf("%s", s); for(int i = 0; i < t; i++)
reverse(); printf("%s", s); return 0; }

#include<cstdio> using namespace std; int N, K, res = 0; void solve(int x) {
int sum = 0; while(x > 0) { if(x % 2 == 1) sum++; x = x/2; } if(sum == K) res++;
} int main() { scanf("%d%d", &N, &K); for(int i = 1; i <= N; i++) solve(i);
printf("%d\n", res); return 0; }

#include<cstdio> #include<stack> using namespace std; const int MAX_N = 1000000
+10; int n, m, L, R;; char s[MAX_N]; void rev() { for(int i = 0; L+i <= R; i++)
{ if(s[L+i] == '(') s[L+i] = ')'; else s[L+i] = '('; } } int isLawful(int R) {
stack<int> s1; for(int i = 0; L+i <= R; i++) { int ch = s[L+i]; if(ch == '(') s1
.push(ch); else if(!s1.empty() && ch==')' && s1.top() == '(') { s1.pop(); } else
{ s1.push(ch); } } if(s1.empty()) return 1; else return 0; } void solve() { for(
int i = n; i > L; i--) { if(isLawful(i)) { printf("%d\n", i); return; } } printf
("%d\n", 0); } int main() { scanf("%d%d", &n, &m); scanf("%s", s+1); //

scanf("%d%d", &L, &R); rev(); } else { scanf("%d", &L); solve(); } } return 0; }

#include<cstdio> #include<algorithm> using namespace std; int T, n, res = 0;
void solve() { for(int a = 1; a <= n; a++) { for(int b = 1; b <= n; b++) { for(
int c = 1; c <= min(n, a+b-1); c++) { if(a+b<=c || a+c<=b || b+c<=a) continue;
if((a^b^c) == 0) res++; } } } } int main() { scanf("%d", &T); for(int i = 0; i <
T; i++) { scanf("%d", &n); solve(); printf("%d\n", res); } return 0; }

Toolsou
API参考文档