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 |
太难了,nlogn都严重超时//TLE #include <iostream> #include <memory> using namespace std; int a[10000000],al,i; int GetID(int n) { int j,k,l; j=-1;k=i; while (j<k-1) { l=(j+k)/2; if (a[l]==n) return 0; if (a[l]>n) k=l; else j=l; } return k+1; } int main() { int j; a[0]=1;al=1; for (i=1,j=1;i<10000000;i++) { for (j++;;j++) { if (j%2==1 && !GetID(j/2)) break; if (j%3==1 && !GetID(j/3)) break; } a[i]=j; } while (cin>>i) cout<<a[i-1]<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator