| ||||||||||
| 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 | |||||||||
为什么是wrong answer啊?请各位帮帮忙!#include <stdio.h>
#include <math.h>
void main(){
int a,b,i,k,s=1,t,x,y;
scanf("%d %d",&a,&b);
while(a!=b){
s=1;
if(a>b){x=b;y=a;}
else if(a<b){x=a;y=b;}
for(i=x;i<=y;i++){
k=i;
t=1;
while(k!=1){
if(k%2==0){ k=k/2; t++;}
else{
k=3*k+1;
t++;}
}
if(t>s) s=t;
}
printf("%d %d %d\n",a,b,s);
scanf("%d %d",&a,&b);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator