UVA 694

#include<iostream>
using namespace std;
int main()
{
    int flag=1;
    long m,n;
    while(cin>>m>>n)
    {
        if(m==-1&&n==-1)
            break;
        long temp=1;
        cout<<"Case "<<flag<<": A = "<<m<<", limit = "<<n<<", number of terms = ";
        while(m>1)
        {
            if(m%2)
                m=m*3+1;
            else
                m/=2;
            if(m>n)break;
            temp++;
        }
        cout<<temp<<endl;
        flag++;
    }
    return 0;

}

 

posted @ 2012-04-28 11:54  open your eyes  阅读(151)  评论(0编辑  收藏  举报