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 |
help me!!it is WA. why?? #include<iostream> using namespace std; long int fun(long int n,long int i) { if(n==1)return i; if(n%2==0) return fun(n/2,i+1); else return fun(3*n+1,i+1); } int main() { long int a,b; int max=1; long int temp; while(cin>>a>>b) { cout<<a<<" "<<b<<" "; if(a>b){ temp=a; a=b; b=temp; } for(int i=a;i<=b;++i) { long int j; j=fun(i,1); if(max<j)max=j; } cout<<max<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator