13479104181461
The idea is elaborated: This question data compares big 100,000, if uses the circulation to do, certainly time out the tle not to discuss. So it must be a bit tricky, for example, with a Boolean array tag, or false if a number satisfies the rule to be marked true in the collection.
In this way, the generation and sequencing of the collection elements are resolved.
Note: Here is a small hole, if the cycle is defined as n=3000000, the direct use of the loop will definitely re, because the subscript out of bounds, this because I also had a gun I did not say the specific reason, hehe O (∩_∩) o~
Well, nonsense not much to say, the good code came!
1#include <stdio.h>2 #defineN 30000013 BOOLk[3*n]={0};4 intaim[n]={0};5 voidf ()6 {7k[1]=true;8 inti,j;9 for(i=1; i<n;i++)Ten if(K[i]) One { Ak[2*i+1]=true; -k[3*i+1]=true; - } thej=0; - for(i=0; i<n;i++) - { - if(K[i]) +aim[j++]=i; - } + A } at intMain () - { - intN; - f (); - while(~SCANF ("%d",&N)) - { inprintf"%d\n", aim[n-1]); - } to return 0; +}
If you have any questions, please leave a message O (∩_∩) o~