| ||||||||||
| 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 | |||||||||
师兄开始恢复了^-^In Reply To:不用链表更快 Posted by:tengshengbo at 2004-09-05 01:14:03 > #include<iostream.h>
> bool check(int i,int j)
> {
> int start=1;
> int x;
> int leng=2*i;
> for(x=1;x<=i;x++)
> {
> start=(start+j-1)%leng;
> if(start==0) start=leng;
> leng--;
> if(start<=i) return false;
> if(start>leng) start=1;
> }
> return true;
> }
> main()
> {
> int a[15];
> int i,j;
> for(i=1;i<14;i++)
> {
> for(j=i+1;;j++)
> {
> if(check(i,j))
> {
> a[i]=j;
> break;
> }
> }
> }
> cin>>i;
> while(i!=0)
> {
> cout<<a[i]<<endl;
> cin>>i;
> }
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator