这题的提议超重要啊。一定要仔细读,静下心来读。还有不要受以前做过什么题听说过什么的干扰。学长让我看这题,并且说这个应该就是素数加密的问题。然后我一直在想素数,看题目提示又不太对劲。再看样例,懵到不知道这题到底要干嘛。所以说啊。。。。
然后这题判断超级多,稍不注意就漏掉了它是几位数的判断,然后我就WA 了。
就按照题意模拟+判断就好了。
顺便学了一下HASH, O(1)复杂度
(反正给出的数字都来自于集合{1,2,3,4,5,6,7,8,9})
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
int h[10];
bool judge(int i)
{
while(i) {
if(!h[i % 10]) return false;
i /= 10;
}
return true;
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int n, x, cnt = 0, la, fi, r1, r2, m;
scanf("%d", &n);
while(n--) {
scanf("%d", &x);
h[x] = 1;
}
for(int i = 100; i < 1000; i++) {
if(!judge(i)) continue;
for(int j = 10; j < 100; j++) {
if(!judge(j)) continue;
m = i * j;
if(m > 9999 || !judge(m)) continue;
la = j % 10;
fi = j / 10;
r1 = i * la;
r2 = i * fi;
if(r1 < 100 || r1 > 999) continue;
if(r2 < 100 || r2 > 999) continue;
if(!judge(r1) || !judge(r2)) continue;
cnt++;
}
}
printf("%d\n", cnt);
return 0;
}
/**/