#include<iostream>usingnamespace std;intget(int x){int res =0;while(x){
res += x %10==2;
x /=10;}return res;}intmain(){// 请在此输入您的代码int cnt =0;for(int i =1; i <=2020; i ++){
cnt +=get(i);}
cout << cnt << endl;return0;}
既约分数
#include<iostream>usingnamespace std;intgcd(int a,int b){return b ?gcd(b, a % b): a;}intmain(){// 请在此输入您的代码int cnt =0;for(int i =1; i <=2020; i ++)for(int j =1; j <=2020; j ++)if(gcd(i, j)==1) cnt ++;
cout << cnt << endl;return0;}
#include<iostream>usingnamespace std;int a[10];boolcheck(int x){while(x){if(--a[x %10]<0)returnfalse;
x /=10;}returntrue;}intmain(){// 请在此输入您的代码int i;for(i =0; i <=9; i ++) a[i]=2021;for(i =1; i; i ++){if(!check(i))break;}
cout << i -1<< endl;return0;}
#include<iostream>usingnamespace std;boolcheck(int x){for(int i =1; i <=4; i ++){if(x %5!= i)returnfalse;
x -= i;
x /=5;
x *=4;}return x %5==0&&!x;}intmain(){for(int i =1; i <=1000000; i +=5){if(check(i)){
cout << i << endl;return0;}}return0;}