| ||||||||||
| 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:给两组数据吧,测试数据都能过,就是WA啊。In Reply To:给两组数据吧,测试数据都能过,就是WA啊。 Posted by:plich at 2006-11-15 17:11:24 > 希望哪位有耐心的大牛帮看一下
> #include<stdio.h>
> int cycleL(int n)
> {
> int c=1;
> while(1)
> {
> if(n==1)
> break;
> else {
> if(n%2==1)
> n=3*n+1;
> else n=n/2;
> c++;
> }
> }
> return c;
> }
> int main(){
> int m=1,i,j,c;
> while(i!=1||j!=1)
> {
> scanf("%i%i",&i,&j);
> if(i<=j)
> for(c=i;c<=j;c++)
> m=(cycleL(c)>m)?cycleL(c):m;
> else
> for(c=j;c<=i;c++)
> m=(cycleL(c)>m)?cycleL(c):m;
> printf("%i %i %i",i,j,m);
> m=1;
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator