The following are the answers submitted by individuals on the field , You are welcome to point out your mistakes , Correct answers will be corrected later .
Individual submission :25
explain : Mbps yes M bit per second, MB yes M Byte,bit It's bit ,Byte It's a byte ,1Byte=8bit, 200/8=25
Individual submission :21844 ( Wrong )
correction :1903
explain : Only every bit is 1,3,5,7 One is the pure prime number . Another condition was not noticed at that time , The number itself is a prime , We should use the sieve method first .
code :
#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 by x One digit number of 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; }
Individual submission :977
explain : It's too troublesome to write the date on site , Direct use excel Data , Then use c handle
First in excel Type in these two boxes , Third, make a difference , See how many days there are
have to 7699, from A1 Drop the grid down 7669 that 's ok , Get from 2001/1/1 reach 2021/12/31 Every day of the year
In order to facilitate the processing of data , Delete what you didn't use just now , And save the form as .csv file
There's data , Direct select all replication , Next, use c/c++ handle
#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; } }
Get the results 977
Individual submission :2667336761
explain : can't dp, Bet on a complete binary tree
#include<iostream> using namespace std; const int MAX_N = 2021;
// Number of nodes , The node is represented by the number of complete binary tree 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; }
code :
#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; }
Conventional writing , too 40% Use cases , Comments on Dichotomy , Before I thought of using the arithmetic sequence in the examination room n Items and according to R-L The value of is a piecewise function , But there was no time to change , Later supplement
#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; }
No rules , Hard writing , too 40% Use cases
Comment area boss said looking for circulation Festival , Later supplement
#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; }
can't dp, Hard written 30% Use cases
#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; }
Simple bracket matching ( Stack ), I don't know how many use cases I can pass
Comment area on line segment tree , Later supplement
#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); //
Make index and L,R agreement for(int i = 0; i < m; i++) { int k = 0; scanf("%d", &k); if(k == 1) {
scanf("%d%d", &L, &R); rev(); } else { scanf("%d", &L); solve(); } } return 0; }
Hard writing , Barely 10% Use cases
It took more than an hour to make a mistake in the examination room , And a structure , put to set Go to heavy , The operator is then overloaded , It turns out that there's no need at all , Ha ha ha , In the future, we should write an outline first , Look at the sample input and output , Go on .
by the way , XOR operator ^ Lower priority , Remember to add brackets
#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; }
Let's start here , I'm going to prepare for the final exam ~
Continue to correct after the examination
Technology