Prime triple (Nanyang oj1156)

Source: Internet
Author: User

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 ;}
       
      
     

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.