-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathaproach_indu.py
41 lines (36 loc) · 901 Bytes
/
aproach_indu.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
def function(N):
dic = {}
for i in range(0,N):
dic[i] = []
arr = [1]
while(True):
bol = True
a = 10**20
for x in arr:
dic[x%N].append(x)
print dic
if(len(dic[0]) >= 1):
a = min(a,min(dic[0]))
bol = False
if(len(dic[N/2]) >= 1 and N%2 == 0):
a = min(a,2*min(dic[N/2]))
bol = False
for i in range(1,N/2+1):
if(len(dic[i]) >= 1 and len(dic[N-i]) >= 1):
a = min(a,(min(dic[i])+min(dic[N-i])))
bol = False
if(not bol):
return a
temp = []
for x in arr:
y1 = int(str(x)+'0')
y2 = int(str(x)+'1')
temp += [y1,y2]
arr = temp
print arr
T = 0
for n in range(1,101):
if(n%100 == 0):
print n,T
T += function(n)/n
print T