A题 宽带

B题 纯质数

#include <bits/stdc++.h>
using namespace std;
const int maxn = 20210610;
int f[maxn];
void init(){
f[1]=1,f[0]=1;
for(int i=2;i<maxn;i++){
if(f[i]==0){
for(int j=2;j*i<maxn;j++){
f[i*j]=1;
}
}
}
}
bool check(int x){
while(x>0){
if(f[x%10]){
return false;
}
x/=10;
}
return true;
}
int main(){
int ans=0;
init();
for(int i=2;i<=20210605;i++){
if(f[i]==0){
if(check(i)){
cout<<i<<endl;
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}
C题 完全日期

#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5*2+5;
int f[maxn];
bool Run(int year){
if( (year%4==0 && year%100!=0) || (year%400==0) ){
return true;
}
return false;
}
bool check(int y,int m,int d){
int sum=0;
while(y>0){
sum+=y%10;
y/=10;
}
while(m>0){
sum+=m%10;
m/=10;
}
while(d>0){
sum+=d%10;
d/=10;
}
if(f[sum]==1){
return true;
}
return false;
}
void init(){
f[1]=1;
for(int i=2;i*i<maxn;i++){
f[i*i]=1;
}
}
int main(){
init();
int ans=0;
for(int i=2001;i<=2021;i++){
int m[13]={
0,
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31
};
if(Run(i)){
m[2]++;
}
for(int j=1;j<=12;j++){
for(int k=1;k<=m[j];k++){
if(check(i,j,k)){
cout<<"年"<<i<<"月"<<j<<"日"<<k<<endl;
ans++;
}
}
}
}
cout<<ans<<endl;
return 0;
}
D题 最小权值
#include <bits/stdc++.h>
using namespace std;
const int maxn=2022;
#define ll long long
ll f[maxn],w[maxn];
void get(int c,int x,int l,int r){
if(x>2021)return ;
if(l<=2021){
f[c]++;
get(c,l,l*2,l*2+1);
}
if(r<=2021){
f[c]++;
get(c,r,r*2,r*2+1);
}
}
int main(){
for(int i=1;i<=2021;i++){
f[i]=0,w[i]=0;
}
for(int i=1;i<=2021;i++){
get(i,i,i*2,i*2+1);
}
for(int i=2021;i>=1;i--){
if(2*i>2021 && 2*i+1>2021){
w[i]=0;
continue;
}
w[i]=1;
int mark=0;
if(i*2<=2021){
w[i]+=2*w[i*2];
mark++;
}
if(i*2+1<=2021){
w[i]+=3*w[i*2+1];
mark++;
}
if(mark==2){
w[i]+=(f[i*2]*f[i*2])*f[i*2+1];
}
}
cout<<w[1]<<endl;
return 0;
}
E题 大写

#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
while(cin>>s){
for(int i=0;i<s.length();i++){
if(s[i]>='a'&&s[i]<='z'){
s[i]-=32;
}
cout<<s[i];
}cout<<endl;
}
return 0;
}
F题 123

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e8+5;
int a[maxn],w[maxn];
int main(){
int k=1,d=1;
for(int i=1;i<maxn;i++){
if(d<k){
a[i]=d;d++;
}else{
i--;d=1;k++;
}
}
w[1]=a[1];
for(int i=2;i<maxn;i++){
w[i]=w[i-1]+a[i];
}
int t;
scanf("%d",&t);
int x,y;
while(t--){
scanf("%d %d",&x,&y);
if(x==y){
printf("%d\n",a[x]);
}else{
printf("%d\n",w[y]-w[x]+a[x]);
}
}
return 0;
}
G题 异或变换

#include <bits/stdc++.h>
using namespace std;
int main(){
int n,t;
int x,y;
while(scanf("%d %d",&n,&t)!=EOF){
string s,b;
cin>>s;
b=s;
while(t--){
for(int i=1;i<s.length();i++){
x=s[i-1]-'0';
y=s[i]-'0';
x=x^y;
b[i]=x+'0';
}
s=b;
}
cout<<s<<endl;
}
return 0;
}
H题 二进制问题

#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k;
while(scanf("%d %d",&n,&k)!=EOF){
int sum=0,ans,j;
for(int i=1;i<=n;i++){
ans=0,j=i;
while(1){
if( j&1 ){
ans++;
}
j= j >> 1;
if(j==0)break;
}
if(ans==k){
sum++;
}
}
printf("%d\n",sum);
}
return 0;
}
I题 翻转括号序列

#include <bits/stdc++.h>
using namespace std;
string s;
void rev(int l,int r){
for(int i=l;i<=r;i++){
if(s[i]=='('){
s[i]=')';
}else{
s[i]='(';
}
}
}
int check(int l){
if(s[l]==')')return 0;
int left = 1,right = 0,mark=0;
for(int i=l+1;i<s.length();i++){
if(left<right)return i-1;
if(s[i]=='('){
left++;
}
if(s[i]==')'){
right++;
}
if(left==right){
mark=i+1;
}
}
return mark;
}
int main(){
int n,m;
while(scanf("%d %d",&n,&m)!=EOF){
cin>>s;
while(m--){
int op,l,r;
scanf("%d",&op);
switch(op){
case 1:
scanf("%d %d",&l,&r);
rev(l-1,r-1);
break;
case 2:
scanf("%d",&l);
printf("%d\n",check(l-1));
break;
}
}
}
return 0;
}
J题 异或三角

#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool check(int i,int j,int k){
if(i+j<=k || i+k<=j || j+k<=i ){
return false;
}
int temp = i^j;
temp = temp^k;
if(!temp)return true;
return false;
}
int main(){
int T;
scanf("%d",&T);
ll n;
while(T--){
cin>>n;
ll ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int k=1;k<=n;k++){
if(check(i,j,k)){
ans++;
}
}
}
}
cout<<ans<<endl;
}
return 0;
}