-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTwo buttons.py
49 lines (44 loc) · 1.01 KB
/
Two buttons.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Created on Tue May 11 01:29:11 2021
@author: 007ki
"""
a=input()
A=a.split()
n=int(A[0])
m=int(A[1])
count=0
temp=n
if n>m:
count=n-m
print(count)
else:
if n==m:
print(count)
else:
if n==1 and m==2:
print(1)
elif m%n==0:
count=m/n
print(int(count))
elif m/2>temp:
while temp<m:
temp=temp*2
count=count+1
count=count+1
midistn=min(int(temp/2-m/2),temp-m)
count=count+midistn
print(int(count))
elif m/2==temp:
count=count+1
print(count)
else:
count=count+1
if int(temp-m/2)==temp-m/2:
midistn=min(int(temp-m/2),temp*2-m)
count=count+midistn
print(int(count))
else:
midistn=min(int(temp-m/2)+1,temp*2-m)
count=count+midistn
print(int(count))