Prime triple (Nanyang oj1156)
Prime triple time limit: 1000 MS | memory limit: 65535 KB difficulty: 1
-
Description
-
The fact that the three adjacent odd numbers are all prime numbers is rare, that is, the three odd numbers P-2, p, p + 2 are all prime numbers, thus forming a prime number triple. Find out all such prime three tuples whose numbers do not exceed n.
-
Input
-
Multiple groups of data are input. Each group of test data is a positive integer of n, n <= 5000000.
-
Output
-
The output size cannot exceed n for all the primarykey three tuples. Each row outputs the three numbers of a triple in the ascending order, and the two numbers are separated by spaces. If such a prime triple does not exist, output "No triple ".
-
Sample Input
-
1
-
Sample output
-
No triple
-
Prompt
-
○ | ~ | _
-
Source
-
Love life
-
Uploaded
TCM _ Zhang Peng
// Table hitting with prime numbers times out !!! It seems that the new method is used to determine the prime number !!! /* # Include
# Include
# Define N 5000010int s [N] = {1, 1, 0}; int main () {int I, j, n, k; for (I = 2; I * I
Int main () {int n; while (scanf ("% d", & n )! = EOF) {if (n> = 7) printf ("3 5 7 \ n"); elseprintf ("No triple \ n");} return 0 ;}