Problem:


Score: 100 points

Problem Statement

Takahashi the Jumbo will practice golf.

His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).

If he can achieve the objective, print OK; if he cannot, print NG.

Constraints

All values in input are integers.

1 \leq A \leq B \leq 1000

1 \leq K \leq 1000

Input

Input is given from Standard Input in the following format:

K
A B

Output

If he can achieve the objective, print OK; if he cannot, print NG.

Sample Input 1

7
500 600

Sample Output 1

OK

Among the multiples of 7, for example, 567 lies between 500 and 600.

Sample Input 2

4
5 7

Sample Output 2

NG

No multiple of 4 lies between 5 and 7.

Sample Input 3

1
11 11

Sample Output 3

OK



Sample input:
7
500 600


Sample output:
OK

Submission status: Runtime Error

Solution code:
N, M, Q = map(int, input().split())
ABCD = [tuple(map(int, input().split())) for _ in range(Q)]

stack = [i for i in range(1, M + 1)]

for i in range(N - 1):
    tmp = []
    while stack:
        now = stack.pop()
        start = now % 10
        for i in range(start, M + 1):
            tmp.append(now * 10 + i)
    stack = tmp

ans = 0
for tmp in stack:
    point = 0
    tmp1 = str(tmp)
    for a, b, c, d in ABCD:
        if int(tmp1[b - 1]) - int(tmp1[a - 1]) == c:
            point += d
    ans = max(ans, point)

print (ans)
# print (stack)

Submission status: Runtime Error

Solution code:
import math
A,B,N=map(int,input().split())
x=min(B-1,N)
ans=math.floor(A*x/B)-A*math.floor(x/B)
print(int(ans))

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = map(int, input().split())

i = B - A

for i in range(A, B + 1):
    if i % K == 0:
        c = 1

if c == 1:
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
import math
A,B,N=map(int,input().split())
x=min(B-1,N)
ans=math.ceil(A*x/B)-A*math.ceil(x/B)
print(int(ans))

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = map(int, input().split())

i = B - A

for i in range(A, B + 1):
    if i % K == 0:
        c = 1

if c == 1:
    orint('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
import itertools

n,m,q=map(int,input().split())

lis=[]
for i in range(q):
    lis.append(list(map(int,input().split())))

Alist=[]

for l in itertools.combinations(range(1,n+m),n):
    ll=list(l)
    a=[]
    for i in range(n):
        a.append(ll[i]-i)
    Alist.append(a)

slist=[]
for i in range(len(Alist)):
    s=0
    for j in range(q):
        aj=lis[j][0]
        bj=lis[j][1]
        cj=lis[j][2]
        dj=lis[j][3]
        if Alist[i][bj-1]-Alist[i][aj-1]==cj:
            s+=dj
    slist.append(s)

print(max(slist))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
x=min(B-1,N)
print(int(A*x/B)-A*int(x/B))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
f = max(n, b-1)

print((a*f)//b -a*(f//b))

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = list(map(int, input().split()))

N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

Submission status: Runtime Error

Solution code:
N, M, Q = map(int, input().split())
li = []
for q in range(Q):
    a, b, c, d = map(int, input().split())
    li.append([[a,b], c, d])
ok_list = []
def dfs(num_li, depth):
    if len(num_li) == N:
        ok_list.append(num_li)
        return
    if depth == M:
        return
    dfs(num_li, depth+1)
    while len(num_li) <N:
        num_li += str(depth)
        dfs(num_li, depth+1)
dfs("", 0)
maxpoint = 0
for ok in ok_list:
    point = 0
    for q in range(Q):
        if int(ok[li[q][0][1]-1])- int(ok[li[q][0][0]-1]) == li[q][1]:
            point += li[q][2]
    if point > maxpoint:
        maxpoint = point
print(maxpoint)
N, M, Q = map(int, input().split())
li = []
for q in range(Q):
    a, b, c, d = map(int, input().split())
    li.append([[a,b], c, d])
ok_list = []
def dfs(num_li, depth):
    if len(num_li) == N:
        ok_list.append(num_li)
        return
    if depth == M:
        return
    dfs(num_li, depth+1)
    while len(num_li) <N:
        num_li += str(depth)
        dfs(num_li, depth+1)
dfs("", 0)
maxpoint = 0
for ok in ok_list:
    point = 0
    for q in range(Q):
        if int(ok[li[q][0][1]-1])- int(ok[li[q][0][0]-1]) == li[q][1]:
            point += li[q][2]
    if point > maxpoint:
        maxpoint = point
print(maxpoint)

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = map(int, input().split()) 
i = 0
j = 0
if(A==B):
  if(A%K==0):
    print('OK')
  else:
    prin('NG')
for x in range(A, B):
    if A / K == B  or (x % K == 0 or K % x == 0):
        print('OK')
        i += 1
        break
if i == 0:
    print('NG')

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Submission status: Runtime Error

Solution code:
import sys
A, B, N = map(int, input().split())

if N < B :
  print(int(N * A // B) - A * int(N // B))
  sys.exit()
else :
  print(((B-1) * A // B) - A * ((B-1) // B))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(s) for s in input().split(" ")]
t1=A[0]%N
t2=A[1]%N
if ( t1 < t2 ) or ( t1==t2 and A[0]%N ==0 and A[1]%N ==0 ):
  print('OK')
else:
  else('NG')

Submission status: Runtime Error

Solution code:
A, B, N = map(int,input().split())
ans = []

if N >= 100000:
    for i in range(N-200,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
f = [int(A*x/B) - (A * int(x/B)) for x in range(N+1)]
print(max(f))

Submission status: Runtime Error

Solution code:
A, B, N = list(map(int,input().split()))
MAX = float('inf')*(-1)
a = int(A/B)
b = B
if N < B:
    MAX = (A * N // B) - A * (N // B)
else:
    MAX = (A * (B-1) // B) - A * ((B-1) // B)
print(MAX)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())

temp_prev = 0
temp_curr = 0
x = min(n, b-1)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr <= temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Runtime Error

Solution code:
target = int(input())
min_range = int(input())
max_range = int (input())
list_range = list(range(min_range, max_range,))
jadge = 1
i = 1
for i in range(100):
    target = target * i


print("NG")

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An = fl(N)

if  B == 1 :
    An = int(0)

if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B == N :
    An = fl(N-1)

print(str(An))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])

Submission status: Runtime Error

Solution code:
import math
import itertools

N,M,Q = map(int,input().split())
a =[0] * Q
b =[0] * Q
c =[0] * Q
d =[0] * Q
for i in range(Q):
    a[i] , b[i] , c[i] , d[i] = map(int,input().split())





def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



All =[0] * M
for i in range(M):
    All[i] = i+1

#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。
#Nの値が小さそうなので全検索でもいけるかもしれへん。



#M個のうちからN個取り出す順列
ans = 0
#for A in itertools.combinations(All, N):
for A in itertools.product(All, repeat=N):
    
    
    #点数計算
    #print(A)
    wa = 0
    for i in range(Q):
        #print(wa) 
        kari = A[b[i]-1] - A[a[i]-1]
        if kari == c[i]:
            wa = wa + d[i] 
    if ans < wa:
        ans = wa
    #print(ans) 
    #print(wa) 


print(ans)

Submission status: Runtime Error

Solution code:
from math import floor
a,b,n=map(int,input().split())
if(n<b):
  print(floor((a*n)/b))
else:
  if(n%b<(n/2)):
    for i in range(0,(n%b)+1):
      print(floor((a*(n-1-i))/b)-(a*floor((n-1-i)/b)))
  else:
    print(floor((a*(n))/b)-(a*floor((n)/b)))

Submission status: Runtime Error

Solution code:
import sys
K=int(input())
A,B=map(int,input().split())
for i in range(A,B):
  if i%K==0:
    print("OK")
    sys.sxit()
print("NG")

Submission status: Runtime Error

Solution code:
import math
import bisect
from collections import deque

N=int(input())
a=list(map(int,input().split()))
u=[]
v=[]
road=[[] for i in range(N)]
for i in range(N-1):
  u1,v1=map(int,input().split())
  road[u1-1].append(v1-1)
  road[v1-1].append(u1-1)
  
#幅優先探索BFSか
ans=[0]*N
houmon=[0]*N
s=deque([])
s.append(0)
dp=[[] for i in range(N)]
dp[0].append(a[0])
while(s):
  v=s.popleft()
  for x in road[v]:#vから行ける場所x
    if(houmon[x]==0):
      dp[x].extend(dp[v])
      s.append(x)
      dp[x].append(a[x])
  houmon[v]=1
  #print(dp)
for i in range(N):
  seq=dp[i]
  #print(seq)
  LIS = [seq[0]]
  for i in range(len(seq)):
    if seq[i] > LIS[-1]:
      LIS.append(seq[i])
    else:
      LIS[bisect.bisect_left(LIS, seq[i])] = seq[i]
  print(len(LIS))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
for i in range(M):
    print(str(i+1) + ' ' + str(N-i-1))

Submission status: Runtime Error

Solution code:
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[0][1]
n = listA[0][2]

old = 0
for x in range(1,n+1):
  if x == 1:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    old = c-(a*d)
  else:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    current = c-(a*d)
    if old <= current:
      old = current
  if x > 10000000:
    break
print (old)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split())) 
B = list(range(A[0],A[1]))
C = 0 
for i in 1000:
    if i*N in B:
        print("OK")
        break
    C += 1
    if C == 1000:
        print("NG")

Submission status: Runtime Error

Solution code:
K,A,B = map(int,input().split())
for i in range(1,1000,K):
    if  A <= i and i <= B:
        print('OK')
        break
else:
    print('NG')

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
for i in range(m):
    print(m-i+1,m+2+i)

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An = fl(N)

if A == 1 : 
    if  B == 1 :
        An = int(0)

if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B == N :
    An = fl(N-1)

print(str(An))

Submission status: Runtime Error

Solution code:
import math
a,b,n = map(int,input().split())
kk = []
for i in range(n):
  kk.append(math.floor(a*n/b)-a*math.floor(n/b))
  n -= 1
print(max(kk))

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(s) for s in input().split(" ")]
t1=A[0]%N
t2=A[1]%N
if ( t1 < t2 ) or ( A[0]%N!=0 and A[1]%N!=0 ):
  print('OK')
else:
  else('NG')

Submission status: Runtime Error

Solution code:
S = input()
A,B = input()
if S in range (A,B):
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
ma=-1
ans=a*n
print(math.floor(ans/b))

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An = fl(N)

if A == 1 and B == 1 :
    An = int(0)

if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B == N :
    An = fl(N-1)

print(str(An))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = int((a * n) / b) - a * int(n / b)
n = n - 1
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 2
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 3
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 4
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 5
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 6
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 7
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 8
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 9
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 10
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 1)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 2)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 3)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 4)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 5)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 6)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 7)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 8)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 9)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 10)
ans = max(ans, int((a * n) / b) - a * int(n / b))
print(ans)

Submission status: Runtime Error

Solution code:
S = int,input()
A,B = int,input()
if S in range (A,B):
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An =fl(N)

if A == 1 and B == 1 :
    An = 0

if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B == N :
    An = fl(N-1)

print(str(An))

Submission status: Runtime Error

Solution code:
import itertools
n,m,q = map(int,input().split())
group = []
for i in range(q):
  w,x,y,z = map(int,input().split())
  v = (w,x,y,z)
  group.append(v)
#groupに(a,b,c,d)がタプルで入っている
max_value = max(group[i][3] for i in range(len(group)))

#Aの配列を試す

l = [i for i in range(1,m+1)]
h = itertools.combinations_with_replacement(l,n)
array =[]

for v in h:
    array.append(v)
#arrayが全ての配列になった


for j in range(len(array)):
  total = 0
  for i in range(q):
    if array[j][group[i][1]-1] - array[j][group[i][0]-1] == group[i][2]:
      total += group[i][3]
  if total >= max_value:
    max_value = total  

print(max_value)

Submission status: Runtime Error

Solution code:
def f(vs,i):
	# print(vs)
	for j in range(len(vs)):
		if vs[j]+i in vs:
			a = vs[j]
			b = vs[j]+i
			print(a,b)
			vs.remove(a)
			vs.remove(b)
			return

n,m = map(int,input().split())
vs = list(range(1,n+1))

for i in range(1,m+1):
	f(vs,i)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = int((a * n) / b) - a * int(n / b)
n = n - 1
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 2
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 3
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 1)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 2)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 3)
ans = max(ans, int((a * n) / b) - a * int(n / b))
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a,b =map(int,input().split())
m = []
if a != b:
    for x in range(a,b+1):
        if x%n == 0:
            i = m.append(x)
            break

else:
    i = a%n
    if i == 0:
        m.append()

if len(m) != 0:
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
K = int(input())
# スペース区切りの整数の入力
A, B = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
answer = ("NO")
for x in range(A,B,1):
  If x/K = 0:
    answer = ("OK")
print(answer)

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
ans = 0
ans_max = 0
for x in range(1,N+1):
    ans = int(float(A*x)/float(B))-A*int(float(x)/float(B))
    if ans_max < ans:
        ans_max = ans
    if x > A and x > B:
        break
print(ans_max)

Submission status: Runtime Error

Solution code:
S = int,input().split()
A,B = int,input().split()
if S in range (A,B):
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int, input().split()) 
max = -10000
tmp = 0

for i in range(1, n+1):
    tmp = math.floor(a * i / b) - math.floor(i / b)
    if max < tmp:
        max = tmp

print(max)

Submission status: Runtime Error

Solution code:
A, B, N = map(int,input().split())
ans = []
for i in range(N//2,N+1):
    k = (A*i)//B - A*(i//B)
    ans.append(k)
    i = i + 1
    
print(max(ans))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
if N>=B:
    print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
    print(int(A*N/B)-A*int(N/B))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import random
import numpy as np


N, M = [int(x) for x in input().split()]


def try_get(N: int, M: int) -> (bool, list):
    used_flag = np.zeros(N)
    stage_marks = []  # [(v1,v2)]
    ones = np.ones(N)
    for length in reversed(range(1, M+1)):
        numbers = np.arange(N - length) + 1
        numbers = numbers[np.logical_and(used_flag[:(N-length)]==0,used_flag[length:N]==0)]
        if len(numbers) == 0:
            return False, []
        num = np.random.choice(numbers)
        stage_marks.append((num, num + length))
        used_flag[num-1] = 1
        used_flag[num+length-1] = 1

    return True, stage_marks


ok = False
marks = []
while not ok:
    ok, marks = try_get(N, M)

for src, dst in marks:
    print("{} {}".format(src, dst))

Submission status: Runtime Error

Solution code:
K = input()
A, B = map(int, input().split())
for i in range(A, B):
    if i % K == 0:
        print('OK')
        break
else:
    print('NG')

Submission status: Runtime Error

Solution code:
S = (int,input().split())
A,B = (int,input().split())
if S in range (A,B):
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
k = int(input())
a,b = map (int, input().split())
res = "NG"
for i in range(a,b+1):
  if((i%k==0):
     res="OK"
     break
print(res)

Submission status: Runtime Error

Solution code:
import math
import random

A,B,N = map(int,input().split())

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(1000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Submission status: Runtime Error

Solution code:
K = input()
A, B = map(int, input().split())
if B - A % K == 0:
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = [int(x) for x in input()]
res = a//k < b//k or not a%k or not b%k
print('OK' if res else 'NG')

Submission status: Runtime Error

Solution code:
K = input()
A, B = map(int, input().split())
if B - A % K:
    print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
a, b, n = list(map(int, input().split(" ")))

ans = 0

for v in range(1, n+1):
    m = ((a * v)/ b) // 1
    l = a * ((v/b)//1)
    if ans < (m - l):
        ans = (m - l)
print(int(ans))

Submission status: Runtime Error

Solution code:
import math
a, b, n = map(int, input().split())
x= int((1-a)/b)
max = 0
while x < n:
    t1 = int(math.floor((a*x)/b))
    t2 = int(a * math.floor(x/b))
    t3 = t1 - t2
    x+=1
    if(t3 > max):
        max = t3
print(max)

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = [int(x) for x in input()]
res = a//k < b//k or not a%k not b%k
print('OK' if res else 'NG')

Submission status: Runtime Error

Solution code:
A, B, N = map(int,input().split())
if(B-A < N) :
 cal = int((A*N)/B) - A*int(N/B)
 print(cal)
else 
 max = 0
 i=N
 while(1):
  cal = int((A*i)/B) - A*int(i/B)
  if(cal > max):
   max =cal
  i += -1
  if(i < 0):
   print(max)
   break;

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
if N < B:
    print(A*N//B)
else:
    l = [(A*i//B)-(A*(i//B)) for i in range(abs(N-5), N+1)]
    print(max(l))

Submission status: Runtime Error

Solution code:
import math
 
a,b,n = map(int,input().split())
 
ans = list()
for x in range(n+1):
    c = math.floor(a*x / b) - a * math.floor(x/b)
    ans.append(c)
 
print(max(ans))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())

def f(t):
    return int(t)

Max_x=0

for i in range(N):
    if f(A*i/B)-A*f(i/B)<f(A*(i+1)/B)-A*f((i+1)/B):
        Max_x=i+1
        
print(f(A*Max_x/B)-A*f(Max_x/B))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
m=0
if n<=(10**7):


    for x in range(n+1):
        l=int(a*x/b)-a*int(x/b)

        if l>=m:

            m=l

else:
    for x in range(10**6,n+1):


        l=int(a*x/b)-a*int(x/b)
        if l>m:

            m=l
print(m)

Submission status: Runtime Error

Solution code:
K = input("")
A, B = map(int, input().split())
number = False
for i in range(A, B+1):
    if number % K == 0:
        number = True
        
print("OK" if number else "NG")

Submission status: Runtime Error

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=1e-10, max_loop=100):
    #初期値を表示
    num_calc = 0  #計算回数
    #print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        #print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = (x_max +x_min)/2.0
        
        x_mid_max = (x_max +x_mid)/2.0
        x_mid_mim = (x_min +x_mid)/2.0
        
        #探索区間を更新
        if func_f(A,B,x_max) < func_f(A,B,x_mid):
            x_min = x_mid
        elif func_f(A,B,x_min) < func_f(A,B,x_mid):
            x_max = x_mid
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
#print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    solution = bisection(func_f, 0, N,A,B)
    print(-func_f(A,B,solution))

Submission status: Runtime Error

Solution code:
K = int(input('K: '))
A = int(input('A: ')) 
B = int(input('B: '))

x = int(input('x: '))
for x in range(1, 1001):
    if (x%K == 0):
        if (A <= x <= B):
            print('OK')
        else:
            print('NG')
    else:
        print('NG')

Submission status: Runtime Error

Solution code:
from bisect import bisect_left
from collections import deque
import copy
def lis(A: list):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            # Lの末尾よりaが大きければ増加部分列を延長できる
            L.append(a)
        else:
            # そうでなければ、「aより小さい最大要素の次」をaにする
            # 該当位置は、二分探索で特定できる
            L[bisect_left(L, a)] = a
    return len(L)
n = int(input())
a = tuple(map(int, input().split()))
G = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v = map(int, input().split())
    G[u].append(v)
    G[v].append(u)

letu = [[] for _ in range(n+1)]
letu[1].append(1)
que = deque([1])

while que:
    q = que.popleft()

    for nq in G[q]:
        let = copy.deepcopy(letu[q])
        if letu[nq] != []: #seen配列としても使う。seenないと閉路でWA
            continue
        let = let + [nq]
        letu[nq] = let
        que.append(nq)
for j in range(1,n+1):
    tmp = [a[aa-1] for aa in letu[j]]
    print(lis(tmp))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
maxs=0
if a>=b:
    if n>=b:
        maxs=a/b*(b-1)-(a%b*(b-1))%b/b
    else:
        maxs=a/b*n-(a%b*n)%b/b
else:
    if n>=b:
        maxs=(a*(b-1))//b
    else:
        maxs=(a*n)//b
print(int(maxs))

Submission status: Runtime Error

Solution code:
import math 

n = int(input())
a, b = map(int, input().split())

a_round = math.round(a / n)
b_round = math.round(b / n)

if a_round == b_round:
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
maxs=0
if a>=b:
    if n>=b:
        maxs=a/b*(b-1)-(a%b*(b-1))%b/b
    else:
        maxs=a/b*n-(a%b*n)%b/b
else:
    if n>=b:
        maxs={a*(b-1)}//b
    else:
        maxs={a*n}//b
print(int(maxs))

Submission status: Runtime Error

Solution code:
K,A,B = map(int,input().split())
for i in range(1000):
    p=K*i
    if  A <= p and p <= B:
        print('OK')
        break
else:
    print('NG')

Submission status: Runtime Error

Solution code:
K = input()
A = input()
B = input()

list=[]
up = int(A)

for i  in  range(int(B)-int(A)):
	list = list + [up]
	up += 1
list = list + [up]

count = 0

for t in list:
	if int(t) % int(K) ==0:
  		count+=1

if count == 0:
  print('NG')
else:
  print('OK')

Submission status: Runtime Error

Solution code:
K,A,B = map(int,input().split())
for i in range(1000):
    if  A <= K*i and K*i <= B:
        print('OK')
        break
else:
    print('NG')

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = map(int, input().split())
list = [i for i in range(A, B) if i % K == 0]
if len(list) >= 1:
  print("OK")
elif len(list) = 0:
  print("NG")
else:
  exit()

Submission status: Runtime Error

Solution code:
import math
a,b,n=(int(x) for x in input().split())
k =0
for x in range(0,n+1):
    c = math.floor((a*x)/b)-a*math.floor(x/b)
    if c  > k:
        k = c
print(k)

Submission status: Runtime Error

Solution code:
import itertools

n, m, q = map(int, input().split())

nums = []
for _ in range(q):
    nums.append(list(map(int, input().split())))

total = 0

l = [1,2,3,4,5,6,7,8,9,10]
for v in itertools.combinations_with_replacement(l, n):
    scores = []
    for a,b,c,d in nums:
        if v[b-1]-v[a-1] == c:
            scores.append(d)
        else:
            scores.append(0)
    if total <= sum(scores):
        total = sum(scores)

print(total)

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

if B > N :
    An =fl(N)
else :
    for i in range(B,N) :
        if i >= 2 and fl(i) < fl(i-1) :
            An = fl(i-1)
            break
        else:
            An = fl(N)


print(str(An))

Submission status: Runtime Error

Solution code:
import math
from sys import stdin
input = stdin.readline
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  sTgt_past=0
  if(N//B>=1):
    print(A-1)
  else:
    for i in range(1,B):
      sTgt=(A*i//B)-A*(i//B)
      if(i==1):
        sMax=sTgt
      else:
        sMax=max(sMax,sTgt)
      sTgt_past=sMax
    print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
import sys

k, tmp = [line.rstrip() for line in sys.stdin]
k, a, b = int(k), [int(x) for x in tmp.split()]
print(a//k < b//k)

Submission status: Runtime Error

Solution code:
K = int(input())
A = int(input())
B = int(input())

if K == 1 :
    print('OK')

elif (B - A) >= K :
   print('OK')

else :
   print('NG')

Submission status: Runtime Error

Solution code:
K=(int(x) for x in input())
A,B=(int(x) for x in input().split())
int(B-1)
for  i in range(A,B-1):
    int(i)
    if i % K == 0:
        break
        print("OK")
    else:
        continue

if B % K == 0:
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
k, a, b = map(int, input().split())
f = 1
while a <= b:
	if (a % k == 0):
		f = 0
		print ("OK")
		break
	a += 1
if f:
	print ("NG")

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
print(n)

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = map(int, input().split())

if k >= 2 and b - a >= k - 1:
  print("OK")
elif k == a or k == b:
  print("OK")
elif a < k  and k < b:
  print("OK")
print k == 1:
  print("OK")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
K,A,B = map(int,input().split())
for i in range(1000):
    if  A <= K*i and K*i <= B:
        print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0

for x in range(1, A[2]+1):
  if i_max < ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    i_max = ((A[0]*x)//A[1]-A[0]*(x//A[1]))
    i_count = x
  if (x - i_count) == 1:
    j_count = j_count + 1
  if (j_count == 2):
    break
    
print(i_count)

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = map(int, input().split())

if k < a:
  if k >= 2:
    if b - a >= k - 1:
      print("OK")
elif k == a or k == b:
  print("OK")
elif a < k  and k < b:
  print("OK")
print k == 1:
  print("OK")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
K,A,B = map(int,input().split())
for i in range(B):
    if  A <= K*i and K*i <= B:
        print('OK')
else:
    print('NG')

Submission status: Runtime Error

Solution code:
k = int(input())
a, b = map(int, input().split())

if k < a:
  if k >= 2:
    if b - a >= k - 1:
    print("OK")
elif k == a or k == b:
  print("OK")
elif a < k  and k < b:
  print("OK")
print k == 1:
  print("OK")
else:
  print("NO")

Submission status: Runtime Error

Solution code:

k =int(input())
a, b = map(int, input().split())
 
for i in range(a, b):
    j = i % k
    if (j == 0):
        break
   
if(j == 0):
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

Solution code:
K = int(input())
A, B = map(int, input().split())
l = [i for i in range(A, B) if i % K == 0]
if l > 0:
  print("OK")
else:
  print("NG")

Submission status: Runtime Error

Solution code:
from math import floor
A, B , N = map(int, input().split())
List = []
for x in range(N+1):
    Answer = floor((A*x)/B) - (A*floor(x/B))
    List.append(Answer)
# print(List)
print(max(List))

Submission status: Runtime Error

Solution code:
K = input()
A, B = map(int, input().split())

A = int(A)
B = int(B)
K = int(K)

C = 0

if A => B:
    print('NG')
else:
    for i in range(A, B):
        if i % K == 0:
            C = 1
    if C == 1:
        print('OK')
    else:
        print('NG')

Submission status: Runtime Error

Solution code:
A, B, N = map(int,input().split())

x = N
for x in reversed(range(1,N+1)):
  if x % B != 0:
    print(int(A*x/B)-A*int(x/B))
    exit()

    
print("0")

Submission status: Runtime Error

Solution code:
k = int(input())
x,y = map(int,input().split())

 for i in range(x,y):
     if i % k == 0:


           print('OK')
 else:

     print('NG')