Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴一个C++,供参考

Posted by wwwaaannngggrs at 2010-06-04 22:31:22 on Problem 2244
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator