hdu 4715

时间:2023-11-23 16:34:56

#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;

}