Codevs 2947 Hunger Series

Source: Internet
Author: User

Title Description Description

Iahub and Iahubina went to a fancy restaurant to date, but when the bill was paid, the cashier did not charge them for the meal, but asked them to write a series. The requirements for this sequence are as follows:

1, the length of the sequence is n

2, for any of the two of the sequence to meet the i<j of the number of AI, AJ, the requirements of Ai<aj.

3, for any of the two of the sequence of i<j to meet the number of AI, AJ, the AI can not be divisible into AJ.

Enter a description Input Description

A number n

Output description Output Description

A row, n number, the series.

If there are many feasible series, the output dictionary is the smallest one.

Sample input Sample Input

3

Sample output Sample Output

2 3 5

Data range and Tips Data Size & Hint

0<n<=105

Code:
/*Sieve Method*/#include<cstdio>using namespacestd;intN,tot;BOOLa[1300001];voidShai () { for(Long LongI=2; i<=1300000; i++)      if(a[i]==0)         for(Long Longj=2*i;j<=1300000; j+=i) a[j]=1;}intMain () {scanf ("%d",&N); if(n==1) {printf ("1"); return 0; }    Long LongI=2;    Shai ();  while(tot<N) {if(a[i]==0) printf ("%lld", i), tot++; I++; }    return 0;}

Codevs 2947 Hunger Series

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.