| ||||||||||
| 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:同样是循环,我的次数应该还少啊,为什么Time Limit啊?In Reply To:同样是循环,我的次数应该还少啊,为什么Time Limit啊? Posted by:xym at 2005-03-18 00:19:52 > 难道机器测试的时候不是从1试到14么?我的循环明显比较少啊,她的是把所有的情况全算出来再调用啊?
> 这是她的程序……
> #include<iostream.h>
> void main()
> {
> int i,j,min_m[14],k;
> for(i=1;i<14;i++)
> {
> for(j=i+1;;j++)
> {
> int personno=i*2;
> int curposition=0;
> for(int r=1;r<=i;r++)
> {
> int killno=(curposition+j-1)%personno;
> if(killno<i)break;
> personno--;
> curposition=killno%personno;
> }
> if(r>i){min_m[i]=j;break;}
> }
> }
> cin>>k;
> while(k!=0)
> {
> cout<<min_m[k]<<endl;
> cin>>k;
> }
>
> }
>
> 这是我的,循环部分是一样的,我是输入一个K,计算一个值,她是全部计算完了,再调用……
> #include<iostream.h>
> void main()
> {
> int j,k;
> cin>>k;
> while(k!=0)
> {
> for(j=k+1;;j++){
> int personno=k*2;
> int curposition=0;
> for(int r=1;r<=k;r++){
> int killno=(curposition+j-1)%personno;
> if(killno<k)break;
> personno--;
> curposition=killno%personno;
> }
> if(r>k){cout<<j<<endl;break;}
> }
> cin>>k;
> }
> }
> 麻烦高手,大牛指点一下吧……感激不尽……以身……恩……这个还是算了……
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator