问题描述:极简主义代码。
问题链接
03pie’s solution for [UVA-100]:
#include<iostream>
using namespace std;
int clen(int n){
int cl=1;
while(n!=1){
n=(n&1?3*n+1:n>>1);
cl++;
}
return cl;
}
int main(){
int a,b;
while(cin>>a>>b){
int a1=a,b1=b,ans=1;
if(b<a) swap(a,b);
for(int i=a;i<=b;i++)
ans=(ans>clen(i)?ans:clen(i));
cout<<a1<<" "<<b1<<" "<<ans<<endl;
}
return 0;
}