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 |
Re:求教1012算法 (提交总是 OTL)In Reply To:求教1012算法 (提交总是 OTL) Posted by:gonghuapeng at 2008-08-03 10:51:57 #include<iostream> using namespace std; int main() { int k=0; int a[14] = {0}; while( (cin>>k)&&(k!=0) ) { if(a[k]) { cout<<a[k]<<endl; continue; } for(int m=k+1;;m++) { int n=2*k,i=0,flag=0; while(1) { i=(i+m-1)%n; if(i>=0&&i<k) break; else flag++; n--;} if(flag==k) { a[flag] = m; cout<<m<<endl; break; } } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator