ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1086. Cryptography

Here is my code.Please who can tell me why i get WA on test#1?
Posted by Anastas 23 Jun 2007 23:53
#include<stdio.h>

int main()
{
    int i,j;
    bool lab[165001];
    int sim[15001],c=0;
    sim[0]=0;
    j=2;
    while(j<=165000){
        while(!lab[j]) j++;
        sim[++c]=j;
        if(c==15000) break;
        for(i=2*j;i<=165000;i+=j){
            lab[i]=false;
        }j++;
    }int k;
    scanf("%d",&k);
    int *a;
    a=new int[k+1];
    for(i=1;i<=k;i++)    scanf("%d",&a[i]);
    for(i=1;i<=k;i++)    printf("%d\n",sim[a[i]]);
    return 0;
}