Skip to content

Commit

Permalink
A→B
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Jun 6, 2022
1 parent e4debbe commit 7b8fb6d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions greedy_algorithm/16953.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
using namespace std;
int main() {
int a, b, cnt = 1;
cin >> a >> b;
while (1) {
if (b % 10 == 1) {
b /= 10;
cnt++;
}
else if (b % 2 == 0) {
b /= 2;
cnt++;
}
else break;
if (a > b) break;
if (a == b) {
cout << cnt;
return 0;
}
}
cout << -1;
return 0;
}

0 comments on commit 7b8fb6d

Please sign in to comment.