7-57 吸血鬼素数测试增强版 (15 分)
吸血鬼素数是指这样的数:如果两个相同位数的素数,其乘积的组成数字正好与这两个素数的组成数字相同,那么这两个素数都被称为吸血鬼素数,例如,117067=167×701,前后都是由一个“0”,两个“1”,一个“6”,两个“7”组成,而167和701都是素数,那么167和701都是3位吸血鬼素数。 请判断给定的一组数,是否是吸血鬼素数。
输入格式:
有多组测试数据,第一行输入T(小于等于10000),为测试数据的组数,随后T行,每行一个正整数N(小于10000)。
输出格式:
对每一组输入,如果是吸血鬼素数,在一行内输出“YES”,否则输出“NO”。
输入样例:
例如:
2
167
5
输出样例:
在这里给出相应的输出。例如:
YES
NO
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void)
{
int a[]={167,701,281,443,317,461,383,971,563,953,1289,9173,1451,9749,1571,6803,2267,5171,2309,4517,2441,7589,2477,8831,2579,4013,2591,7547,2741,6803,2801,4457,2897,4451,2927,6581,2957,4211,3041,4289,3461,4283,3581,5171,3821,7901,3863,9551,3917,9497,4013,2579,4049,8753,4073,8369,4091,5021,4211,2957,4241,9371,4283,3461,4289,3041,4373,9923,4391,4451,4397,8369,4421,9533,4451,2897,4457,2801,4517,2309,4523,7649,4871,8597,4931,7529,5021,4091,5171,2267,5273,9923,5711,8963,5801,9467,5843,9137,5861,9677,5939,8951,6491,9551,6563,8147,6569,9311,6581,2927,6659,8501,6761,9929,6803,1571,7001,2957,7451,2309,7529,4931,7547,2591,7589,2441,7649,4523,7673,9341,7691,8423,7757,9221,7793,4523,7901,3821,8147,6563,8171,9689,8369,4073,8423,3821,8501,6659,8597,4871,8609,7793,8753,4049,8831,2477,8951,5939,8963,5711,9137,5843,9173,1289,9221,7757,9311,6569,9341,7673,9371,4241,9467,5801,9497,3917,9533,4421,9551,3863,9623,3917,9677,5861,9689,8171,9743,4049,9749,1451,9839,4421,9923,4373,9929,6761,9941,4373};
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int t;
scanf("%d",&t);
int flag = 1;
for(int j=0;j<198;j++){
if(t==a[j]){flag=0;printf("YES\n");break;}
}
if(flag) printf("NO\n");
}
}