#include #include #include using namespace std; int main() { map amap; map bmap; int a,b; int na=-1,nb=-1,sa=-1,sb=-1; int cis=-1; while(true) { amap.clear(); bmap.clear(); a=-1; b=-1; na=-1; nb=-1; sa=-1; sb=-1; cis=-1; scanf("%d%d",&a,&b); if(a==0&&b==0)break; na=a; nb=b; int index=0; while(true) { amap.insert(make_pair(a,index++)); if(a==1)break; if(a%2==0) { a=a/2; } else { a=a*3+1; } } index=0; while(true) { bmap.insert(make_pair(b,index++)); map::iterator iter= amap.find(b); if( iter != amap.end() ) { sa=iter->second; //cout<<"aindex "<second<second; cis=b; //cout<<"bindex "<second<::iterator iter; for( iter = amap.begin(); iter != amap.end(); ++iter ) { cout << "Key: '" << iter->first << "', Value: " << iter->second << endl; } cout <first << "', Value: " << iter->second << endl; } */ cout << na << " needs " << sa<< " steps, "<< nb << " needs " << sb <<" steps, they meet at "<