AcWing 5311. 密码锁
原题链接
简单
作者:
_Kris
,
2024-11-13 17:34:12
,
所有人可见
,
阅读 1
样例
# include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int a[N][5];
int cnt[N];
int main()
{
cin >> n;
for(int i = 0; i < n; i ++)
for(int j = 0; j < 5; j ++)
cin >> a[i][j];
int res = 0;
for(int i = 0; i < n; i ++)
{
for(int j = 0; j < 5; j ++)
{
for(int k = 1; k < 10; k ++)
{
a[i][j] = (a[i][j] + 1) % 10;
int num = a[i][0]*10000 + a[i][1]*1000 + a[i][2]*100 + a[i][3]*10 + a[i][4];
cnt[num] ++;
}
a[i][j] = (a[i][j] + 1) % 10;
}
}
for(int i = 0; i < n; i ++)
{
for(int j = 0; j < 4; j ++)
{
for(int k = 1; k < 10; k ++)
{
a[i][j] = (a[i][j] + 1) % 10;
a[i][j + 1] = (a[i][j + 1] + 1) % 10;
int num = a[i][0]*10000 + a[i][1]*1000 + a[i][2]*100 + a[i][3]*10 + a[i][4];
cnt[num] ++;
}
a[i][j] = (a[i][j] + 1) % 10;
a[i][j + 1] = (a[i][j + 1] + 1) % 10;
}
}
for(int i = 0; i < N; i ++)
if(cnt[i] == n) res ++;
cout << res;
return 0;
}