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++,供参考#include <iostream> using namespace std; int a[2000]; int k; bool ok(int n,int m) { int s=0; int t=n-1; for (int i=1;i<n-1;i++) { s=(s+m-1)%t; t--; if (s==0) return false; } return true; } void solve(int k) { int i=2; while (i<3000000) { if (ok(k,i)) {a[k]=i; return;} i++; } } int main() { for (int k=1;k<=150;k++) { solve(k); } cin>>k; while (k) {cout<<a[k]<<endl; cin>>k;} return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator