暴力解AC
2025-08-31 12:38:32
发布于:北京
40阅读
0回复
0点赞
关---注---我
#include <bits/stdc++.h>
using namespace std;
int n,s[10][6],sum,er[7];
bool check(int er[]){
for(int i=1;i<=n;i++){
int ok=0,w,op;
for(int j=1;j<=5;j++){
if(er[j]!=s[i][j]){
ok++;
if(ok==1){
op=j;
w=(er[j]-s[i][j]+10)%10;
}
else if(ok==2){
if(j-op!=1) return false;
if((er[j]-s[i][j]+10)%10!=w) return false;
}
else return false;
}
if(j==5&&ok==0) return false;
}
}
return true;
}
int main(){
freopen("lock.in","r",stdin);
freopen("lock.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=5;j++){
cin>>s[i][j];
}
}
for(int a=0;a<=9;a++){
for(int b=0;b<=9;b++){
for(int c=0;c<=9;c++){
for(int d=0;d<=9;d++){
for(int e=0;e<=9;e++){
er[1]=a;
er[2]=b;
er[3]=c;
er[4]=d;
er[5]=e;
if(check(er)){sum++;}
}
}
}
}
}
cout<<sum;
fclose(stdin);
fclose(stdout);
return 0;
}
这里空空如也






有帮助,赞一个