-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path广联达.py
58 lines (43 loc) · 1.13 KB
/
广联达.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
50
51
# import math
# import sys
#
# while True:
# n,m = sys.stdin.readline().strip().split()
# sum_ = int(n)
# if int(n) < 0 or int(m) < 0:
# print(0)
# res = []
# for i in range(0,int(m)):
# res.append(sum_)
# sum_ = round(math.sqrt(sum_),2)
#
# re = sum(res)
# print(round(re,2))
import sys
def get_dict(nums):
memo = dict()
n = len(nums)
for i in range(n):
memo[i] = len(set(nums[i:]))
return memo
def get_count(x,memo):
return memo[x]
def get_laste_count(x,y,X,Y):
def dp(i,j):
if i == X and j == Y:
return 0
if i > X or j > Y :
return float("inf")
re = float("inf")
re = min(re,dp(i+1,j+1)+1)
re = min(re,dp(i*2,j*2)+1)
return re
return dp(x,y)
if __name__ == '__main__':
# n,m = list(map(int,sys.stdin.readline().rstrip().split()))
# nums = list(map(int,sys.stdin.readline().rstrip().split()))
# memo = get_dict(nums)
# for _ in range(m):
# x = int(sys.stdin.readline().rstrip())
# print(get_count(x-1,memo))
print(get_laste_count(1,2,4,6))