2023 年第五届河南省 CCPC 大学生程序设计竞赛
Problem A. 小水獭游河南
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string a;
cin>>a;
int st[27],ji=0;
memset(st,0,sizeof(st));
if(a.size()==1)
{
cout<<"NaN"<<endl;
continue;
}
st[a[0]-'a']++;
for(int i=1;i<a.size();i++)
{
st[a[i]-'a']++;
for(int j=i,k=a.size()-1;j<a.size();j++,k--)
{
if(j>=k)
{
cout<<"HE"<<endl;
ji=1;
break;
}
if(a[j]!=a[k])
{
break;
}
}
if(ji==1)
break;
//重点
if(st[a[i]-'a']>1)
{
cout<<"NaN"<<endl;
break;
}
}
};
return 0;
}
Problem C. Toxel 与随机数生成器
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s,b="";
cin>>s;
for(int i=0;i<500;i++)
b+=s[i];
if(s.find(b,1001)==-1)
{
cout<<"Yes";
}else
{
cout<<"No";
}
return 0;
}
Problem F. Art for Last
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int a[n+10],b[n+10],c[n+10],q[n+10];
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
for(int i=1;i<=n-1;i++)b[i]=a[i+1]-a[i];
int h=1,t=0,cnt=1;
for(int i=1;i<=n-1;i++)
{
while(t>=h&&b[q[t]]>=b[i])t--;
q[++t]=i;
if(q[h]<i-k+2)h++;
if(i>=k-1)c[cnt++]=b[q[h]];
}
//重点
long long res=1e18;
for(int i=1;i<=n-k+1;i++)
{
res=min(res,(long long)c[i]*(a[i+k-1]-a[i]));
}
cout<<res;
return 0;
}
Problem G. Toxel 与字符画
#include <bits/stdc++.h>
using namespace std;
char big[10][10][9] = {
{
"........",
"........",
".0000000",
".0.....0",
".0.....0",
".0.....0",
".0.....0",
".0.....0",
".0000000",
"........",
},
{
"........",
"........",
".......1",
".......1",
".......1",
".......1",
".......1",
".......1",
".......1",
"........",
},
{
"........",
"........",
".2222222",
".......2",
".......2",
".2222222",
".2......",
".2......",
".2222222",
"........",
},
{
"........",
"........",
".3333333",
".......3",
".......3",
".3333333",
".......3",
".......3",
".3333333",
"........",
},
{
"........",
"........",
".4.....4",
".4.....4",
".4.....4",
".4444444",
".......4",
".......4",
".......4",
"........",
},
{
"........",
"........",
".5555555",
".5......",
".5......",
".5555555",
".......5",
".......5",
".5555555",
"........",
},
{
"........",
"........",
".6666666",
".6......",
".6......",
".6666666",
".6.....6",
".6.....6",
".6666666",
"........",
},
{
"........",
"........",
".7777777",
".......7",
".......7",
".......7",
".......7",
".......7",
".......7",
"........",
},
{
"........",
"........",
".8888888",
".8.....8",
".8.....8",
".8888888",
".8.....8",
".8.....8",
".8888888",
"........",
},
{
"........",
"........",
".9999999",
".9.....9",
".9.....9",
".9999999",
".......9",
".......9",
".9999999",
"........",
},
};
char sml[10][10][7] = {
{
"......",
".00000",
".0...0",
".0...0",
".0...0",
".00000",
"......",
"......",
"......",
"......",
},
{
"......",
".....1",
".....1",
".....1",
".....1",
".....1",
"......",
"......",
"......",
"......",
},
{
"......",
".22222",
".....2",
".22222",
".2....",
".22222",
"......",
"......",
"......",
"......",
},
{
"......",
".33333",
".....3",
".33333",
".....3",
".33333",
"......",
"......",
"......",
"......",
},
{
"......",
".4...4",
".4...4",
".44444",
".....4",
".....4",
"......",
"......",
"......",
"......",
},
{
"......",
".55555",
".5....",
".55555",
".....5",
".55555",
"......",
"......",
"......",
"......",
},
{
"......",
".66666",
".6....",
".66666",
".6...6",
".66666",
"......",
"......",
"......",
"......",
},
{
"......",
".77777",
".....7",
".....7",
".....7",
".....7",
"......",
"......",
"......",
"......",
},
{
"......",
".88888",
".8...8",
".88888",
".8...8",
".88888",
"......",
"......",
"......",
"......",
},
{
"......",
".99999",
".9...9",
".99999",
".....9",
".99999",
"......",
"......",
"......",
"......",
},
};
char inf[10][25] = {
"........................",
"........................",
".IIIIIII.N.....N.FFFFFFF",
"....I....NN....N.F......",
"....I....N.N...N.F......",
"....I....N..N..N.FFFFFFF",
"....I....N...N.N.F......",
"....I....N....NN.F......",
".IIIIIII.N.....N.F......",
"........................",
};
char den[10][9]{
"........",
"........",
"........",
"........",
".=======",
"........",
".=======",
"........",
"........",
"........",
};
int main()
{
int t;
cin>>t;
while(t--)
{
vector<int> a,b,c;
string m[50];
long long x,y;
scanf("%lld^{%lld}",&x,&y);
long long tx,ty;
tx=x,ty=y;
while(tx)
{
a.push_back(tx%10);
tx/=10;
};
while(ty)
{
b.push_back(ty%10);
ty/=10;
};
reverse(a.begin(),a.end());
reverse(b.begin(),b.end());
for(int i=0;i<10;i++)
{
for(auto k:a)
m[i]+=big[k][i];
for(auto k:b)
m[i]+=sml[k][i];
m[i]+=den[i];
}
__int128 ans=1;
int ji=0;
//重点
if(x!=1)
{
for(long long i=1;i<=y;i++)
{
ans*=x;
if(ans>1e18)
{
ji=1;
break;
}
}
}
if(ji)
{
for(int i=0;i<10;i++)
m[i]+=inf[i];
}else
{
while(ans)
{
c.push_back(ans%10);
ans/=10;
}
reverse(c.begin(),c.end());
for(int i=0;i<10;i++)
{
for(auto k:c)
m[i]+=big[k][i];
}
}
for(int i=0;i<10;i++)m[i]+=".";
for(int i=0;i<10;i++)cout<<m[i]<<endl;
};
return 0;
}
Problem H. Travel Begins
#include <bits/stdc++.h>
using namespace std;
int check(double x)
{
return x-int(x)>=0.5?1:0;
}
int main()
{
int t;
cin>>t;
while(t--)
{
double t=0.000000000001;
int n,k,num,ma,mi;
cin>>n>>k;
if(2*n>k)
num=k-1;
else
num=2*n;
ma=num+int(n-0.5*num)+check(n-0.5*num);
if(2*n==k)
num=2*n-1;
mi=int(n-(0.5-t)*num)+check(n-(0.5-t)*num);
cout<<mi<<" "<<ma<<endl;
}
return 0;
}
标签:int,题解,......,....,.......,2023CCPC,.....,........
From: https://www.cnblogs.com/ckeri/p/18133276