讨论 / PID:239 求改进,总超时
蔡旭昀 2013-02-17 05:45:00
点我顶贴 收藏 删除
代码:

#include<iostream>

using namespace std;

int main()

{

ios::sync_with_stdio(false);

int t;

cin >> t ;

long long a,b,cd,n,tcd;

while(t>=1)

{

cin >> a >> b ;

if(a>b) a^=b,b^=a,a^=b;

cd=0;

while(a<=b)

{

n=a;tcd=0;

while(n>1) {if(n%2) n=n*3+1; else n/=2; ++tcd;}

if(tcd>cd) cd=tcd;

++a;

}

cout << cd << endl;

--t;

}

return 0;

}

#1 蔡旭昀@2013-02-17 05:45:00
回复 删除
UP

UP

查看更多回复
提交回复