短但让人眼前一黑的代码
2026-09-23 19:48:53
发布于:新疆
20阅读
0回复
0点赞
#include<iostream>
using namespace std;
int a[1000000],cnt;
int t(int c){
int answer=1;
while(c--)answer*=10;
return answer;
}
int main(){
freopen("lock.in","r",stdin);
freopen("lock.out","w",stdout);
int n;
cin>>n;
for(int i=1;i<=n;i++){
int S=0;
for(int j=1;j<=5;j++){
int s;
cin>>s;
S=S*10+s;
}
for(int j=0;j<5;j++)
for(int k=1;k<=9;k++){
a[(S+k*t(j))%t(j+1)+S/t(j+1)*t(j+1)]++;
if(j!=4)a[(S/t(j)+k)%10*t(j)+(S/t(j+1)+k)%10*t(j+1)+S/t(j+2)*t(j+2)+S%t(j)]++;
}
}
for(int i=0;i<1000000;i++)if(a[i]==n)cnt++;
cout<<cnt;
fclose(stdin);
fclose(stdout);
return 0;
}
这里空空如也


有帮助,赞一个