hdu 4715

#include<stdio.h>
#include<string.h>
int prime[1100000],p[1000000],ans;
void pri() {
    int i,j,k;
    memset(prime,-1,sizeof(prime));
 prime[0]=prime[1]=0;
    for(i=2;i<=1000;i++)
        if(prime[i]==-1) {
            for(j=i*2;j<=1000000;j+=i)
                prime[j]=0;
        }
        for(i=2;i<=1000000;i++)
            if(prime[i]==-1)
           p[ans++]=i;
}
int main() {
    int t,a,b,x,i;
    ans=0;
    pri();
    scanf("%d",&t);
    while(t--) {
        scanf("%d",&x);
        for(i=0;i<ans;i++)
            if(p[i]>=x&&prime[p[i]-x]==-1)
                break;
            if(i==ans)
                printf("FAIL\n");
            else
            printf("%d %d\n",p[i],p[i]-x);
    }
    return 0;
}
posted @ 2013-09-09 17:34  HYDhyd  阅读(87)  评论(0编辑  收藏  举报