3 6 8 10样例输出5 1 7 1 11 1#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){int n,i,j,ki,kj;scanf("%d",&n); while(n--){ int x,count_i,count_j; scanf("%d",&x); if(x==1){ PRintf("2 1/n"); continue; } for(i=x,j=x;i>1&&j<2*x;i--,j++){ count_i=0; count_j=0; for(ki=sqrt(i);ki>0;ki--) if(i%ki==0) count_i++; if(count_i==1){ printf("%d %d/n",i,abs(x-i)); break; } for(kj=sqrt(j);kj>0;kj--) if(j%kj==0) count_j++; if(count_j==1){ printf("%d %d/n",j,abs(x-j)); break; } } }return 0;}
新闻热点
疑难解答