fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. long long a,b; cin>>a>>b; int count=0;
  6. while(a!=b){
  7. if(b==0) {cout<<"-1"; return 0;}
  8. if(b%2==1) b/=10;
  9. else b/=2; count++;
  10. } cout<<count+1;
  11. }
Success #stdin #stdout 0s 5580KB
stdin
1 15
stdout
2