UVa Problem 100 The 3n+1 problem (3n+1 问题)

时间:2023-03-09 09:08:11
UVa Problem 100 The 3n+1 problem (3n+1 问题)

参考:https://blog.****.net/metaphysis/article/details/6431937

 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
ll a,b;
ll length(ll x)
{
ll l=;
while (x!=)
{
if (x%==)
{
x=*x+;
}
else
{
x=x/;
}
l++;
}
return l;
}
int main()
{
// freopen("text.txt","r",stdin);
while (scanf("%lld %lld",&a,&b)!=EOF)
{
ll ma=;
for (ll i=min(a,b);i<=max(a,b);i++)//注意输入要先排大小!
{
ma=max(ma,length(i));
}
printf("%lld %lld %lld\n",a,b,ma);
} return ;
}