-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc161_c.py
More file actions
38 lines (38 loc) · 752 Bytes
/
abc161_c.py
File metadata and controls
38 lines (38 loc) · 752 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
36
37
38
abc161_c.py
########################################
########################################
########################################
N, K = map(int,input().split())
a = N // K
num = N
ans = N
if N >= K:
num = N - a*K
for i in range(2):
p = K - num
ans = min(ans,p)
num = p
print(ans)
########################################
N,K=map(int,input().split())
R1=N%K
R2=abs(K-R1)
print(min(R1,R2))
########################################
[my WA]
N,K=map(int,input().split())
R1=N%K
R2=K%R1
print(min(R1,R2))
########################################
[my WA]
N,K=map(int,input().split())
def change(x):
x=abs(x-K)
return x
ANS=set()
for i in range(N):
N=change(N)
ANS.add(change(N))
print(min(ANS))
########################################