-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ16953.java
More file actions
35 lines (31 loc) · 978 Bytes
/
BOJ16953.java
File metadata and controls
35 lines (31 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteOrder;
import java.util.StringTokenizer;
public class BOJ16953 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int A = Integer.parseInt(st.nextToken());
int B = Integer.parseInt(st.nextToken());
int count = 1;
while(A != B){
if(B < A){
System.out.print(-1);
return;
}
if(B%10 == 1){
B /= 10;
count++;
}else if(B % 2 == 0){
B /= 2;
count++;
}else{
System.out.print(-1);
return;
}
}
System.out.print(count);
}
}