mid-kid
4 years ago
3 changed files with 24 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||||
|
#!/usr/bin/env python3 |
||||
|
|
||||
|
from sys import argv |
||||
|
|
||||
|
i = open(argv[1]).read().split("\n") |
||||
|
a = int(i[0].strip()) |
||||
|
b = [int(x) if x != "x" else None for x in i[1].strip().split(",")] |
||||
|
|
||||
|
e = sorted([(x, x-(a%x)) for x in b if x], key=lambda x: x[1])[0] |
||||
|
print(e[0]*e[1]) |
||||
|
|
||||
|
ma = [(i, x) for i, x in enumerate(b) if x] |
||||
|
ma.sort(key=lambda x: x[1], reverse=True) |
||||
|
s = ma[0][1]-ma[0][0] |
||||
|
m = ma[0][1] |
||||
|
for i, x in ma[1:]: |
||||
|
while x-(s%x) != (i%x if i%x != 0 else x): |
||||
|
s += m |
||||
|
m *= x |
||||
|
print(s) |
@ -0,0 +1,2 @@ |
|||||
|
1001796 |
||||
|
37,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,457,x,x,x,x,x,x,x,x,x,x,x,x,13,17,x,x,x,x,x,x,x,x,23,x,x,x,x,x,29,x,431,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,19 |
@ -0,0 +1,2 @@ |
|||||
|
261 |
||||
|
807435693182510 |
Loading…
Reference in new issue