Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- long long int a[1000009],b[1000009];
- void del(int i)
- {
- int j,k;
- for(j=2;i*j<1000000;j++){
- k=i*j;
- a[k]=0;
- }
- }
- int main()
- {
- long long int i,j;
- a[1]=0;
- a[2]=-1;
- b[1]=2;
- for(i=3;i<1000000;i++){
- a[i]=-1;
- if(i%2==0)
- a[i]=0;
- }
- i=2;
- j=1;
- while(i<1000000){
- i++;
- if(a[i]==0)
- continue;
- j++;
- b[j]=i;
- del(i);
- }
- int n,x,k;
- scanf("%d",&n);
- for(k=1;k<=n;k++){
- scanf("%d",&x);
- printf("%d\n",b[x]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement