#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
#define putcase2 cout<<"Case #"<<++cse<<":"
using namespace std;
int main()
{
long long a,b,c,i,j=1;
while(scanf("%lld%lld",&b,&c)==2)
{
if(b<0 && c<0)
break;
a=b;
for(i=1;i!=0;i++)
{
if(a==1)
break;
if(a%2==0)
a=a/2;
else
a=a*3+1;
if(a>c)
break;
}
printf("Case %lld: A = %lld, limit = %lld, number of terms = %lld\n",j,b,c,i);
j++;
}
}
return 0;
}
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
#define putcase2 cout<<"Case #"<<++cse<<":"
using namespace std;
int main()
{
long long a,b,c,i,j=1;
while(scanf("%lld%lld",&b,&c)==2)
{
if(b<0 && c<0)
break;
a=b;
for(i=1;i!=0;i++)
{
if(a==1)
break;
if(a%2==0)
a=a/2;
else
a=a*3+1;
if(a>c)
break;
}
printf("Case %lld: A = %lld, limit = %lld, number of terms = %lld\n",j,b,c,i);
j++;
}
}
return 0;
}
No comments:
Post a Comment