Special prime ribs (violent table)

Special prime ribs

Topic description
Farmer John Cow always produces the best ribs.
You can recognize them by the numbers on each rib marked by Farmer John and the USDA.
Farmer John determined that the ribs he sold to the buyer were real prime ribs, because the ribs were cut from the right, and the numbers on the remaining ribs each time constitute a prime number, for example:
7 3 3 1 on
all ribs The number 7331 is a prime number; the three ribs 733 are prime numbers; the two ribs 73 are prime numbers; of course, the last rib 7 is also a prime number.
7331 is called a special prime number of length 4.
Write a program for the given number of ribs N (1<=N<=8) to find all the special prime numbers.
The number 1 is not considered a prime number.

Enter a
single line containing N

Output Output
special prime numbers of length N in order, one per line

Sample input
4

Sample output
2333
2339
2393
2399
2939
3119
3137
3733
3739
3793
3797
5939
7193
7331
7333
7393

#include<stdio.h>
#include<math.h>
int main()
{
    
    
//打表
    int a[100000]={
    
    2,
3,
5,
7,
23,
29,
31,
37,
53,
59,
71,
73,
79,
233,
239,
293,
311,
313,
317,
373,
379,
593,
599,
719,
733,
739,
797,
2333,
2339,
2393,
2399,
2939,
3119,
3137,
3733,
3739,
3793,
3797,
5939,
7193,
7331,
7333,
7393,
23333,
23339,
23399,
23993,
29399,
31193,
31379,
37337,
37339,
37397,
59393,
59399,
71933,
73331,
73939,
233993,
239933,
293999,
373379,
373393,
593933,
593993,
719333,
739391,
739393,
739397,
739399,
2339933,
2399333,
2939999,
3733799,
5939333,
7393913,
7393931,
7393933,
23399339,
29399999,
37337999,
59393339,
73939133,
100000001};
int n,i,j,k;
scanf("%d",&n);
k=pow(10,n);
j=k/10;
for(i=0;;i++)
{
    
       
    if(a[i]>k)
    break;
    if(a[i]>j&&a[i]<k)
    printf("%d\n",a[i]);
 
}
return 0;
}

Violence works miracles, just show the province.

Guess you like

Origin blog.csdn.net/m0_46381590/article/details/111417012