uva 371 - Ackermann Functions

时间:2021-03-08 14:39:53
 #include <cstdio>

 int main()
{
long int F, S, I, Count, Value, Max, J;
while(scanf("%ld %ld", &F, &S) && F)
{
if(F > S) { F ^= S; S ^= F; F ^= S; }
Max = ;
for(I = F; I <= S; I++)
{
Count = ;
J = I;
do{
if(J % ) (J *= ) ++;
else J /= ;
Count ++;
}while(J != );
if(Count > Max) { Value = I; Max = Count; }
}
printf("Between %ld and %ld, %ld generates the longest sequence of %ld values.\n",F, S, Value, Max);
}
return ;
}