1k =int(input())2a, b =list(map(int,input().split()))3s =[i for i inrange(a, b)if i % k ==0]4if a == b and a % k ==0:5print('OK')6eliflen(s)==0:7print('NG')8else:9print('OK')10
1def solve(k, a, b):
2 s = [i for i in range(a, b) if i % k == 0]
3 if a == b and a % k == 0:
4 return "OK"
5 elif len(s) == 0:
6 return "NG"
7 else:
8 return "OK"
910def solve2(k, a, b):
11 if a % k == 0:
12 return "OK"
1314 if (a // k + 1) * k <= b:
15 return "OK"
16 return "NG"
1718def check(k, a, b):
19 for i in range(a, b + 1):
20 if i % k == 0:
21 return "OK"
22 return "NG"
2324TEST = [
25 [[7, 500, 600], "OK"],
26 [[4, 5, 7], "NG"],
27 [[1, 11, 11], "OK"],
28 [[2, 11, 11], "NG"],
2930 [[11, 11, 11], "OK"],
31 [[12, 11, 12], "OK"]
32]
33for t in TEST:
34 k, a, b = t[0]
35 if t[1] != solve(k, a, b):
36 print("Fail ", t)
3738print("-----------------")
39print("solve")
40for k in range(1, 5):
41 for a in range(1, 5):
42 for b in range(a, 5):
43 if check(k, a, b) != solve(k, a, b):
44 print("Fail", k, a, b)
4546N = 200 # 1000
47print("-----------------")
48print("solve2")
49for k in range(1, N + 1):
50 for a in range(1, N + 1):
51 for b in range(a, N + 1):
52 if check(k, a, b) != solve2(k, a, b):
53 print("Fail", k, a, b)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/05 09:22