Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用C++交RE了n多次,用G++居然瞬间AC ,无语。。。虽然只是水过,但是好纠结,无语。。。 代码: #include<iostream> #include<cstdio> using namespace std; const int N=35005; bool v[N+50]; int a[3050]; int main() { int i,j; for(i=1;i<N;i++) { v[i]=1; } for(i=2;i<N/2;i++) { int k=0; j=i+1; if(v[i]) while(j<N) { if(!v[j++]) continue; k++; if(k==i) { v[j-1]=0; k=0; } } } j=1; for(i=2;i<N;i++) { if(v[i]) a[j++]=i; } //cout << j<< endl; int n; while(scanf("%d",&n)!=-1) { if(n==0) break; cout << a[n] << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator