题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=453
今天看到一段比较好的代码,觉得以后还会有用,所以就留了下来.
代码:
#include<stdio.h> int a[270000],b[100002]; void pre() { int i,j; for(i=j=1;i<=100000;j++) { if(a[j]==0) { a[j]=1; a[i+j]=1; b[i]=j; i++; } } } int main() { int t,n; pre(); scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d %d\n",b[n],b[n]+n); } return 0; }