Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def main():
    A,B,N = [int(x) for x in input().split()]
    import math
    ans = int(math.floor(A*min(B-1, N))/B)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# x/B = t + c
# at

# floor(a(t+c))
# floor(a(x%B)/B)
a, b, n = na()
n = min(b-1, n)
print(a*(n%b)//b)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    import math
    input = sys.stdin.readline

    a, b, N = map(int, input().split())
    if N < b:
        print(math.floor(a * N / b))
    else:
        print(math.floor(a * (b-1) / b))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
input = sys.stdin.readline


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


A, B, N = inpl()


def calc(x):
    return (A * x // B) - A * (x // B)


ans = -1

for a in range(1, A + 5):
    x = B * a - 1
    if x > N:
        break
    tmp = calc(x)
    ans = max(ans, tmp)


if ans == -1:
    if N <= A:
        for x in range(N + 1):
            ans = max(ans, calc(x))
    else:
        ans = calc(N)

print(ans)

Submission status: Accepted

Solution code:
a,b,n = [int(i) for i in input().split()]
x = min(n,b -1)
ans = (a*x)//b
print(ans)

Submission status: Accepted

Solution code:
a, b, n = [int(i) for i in input().split()]
x = min(b - 1, n)
print((a*x//b)-a*(x//b))

Submission status: Accepted

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

import sys
import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, n = mi()

    x = min(b - 1, n)
    print(math.floor(a * x / b) - a * math.floor(x / b))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    A, B ,N = read_values()
    print((A * min(N, B - 1)) // B)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

def solve(A,B,N):
    ans = A*min(B-1,N)//B
    return ans
print(solve(A,B,N))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

a, b, n = nm()
if b-1 < n:
    c = (a-1)//b + 1
    print(a - c)
else:
    print(a*n//b - a*(n//b))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
#print(math.floor(A/B))
c=[0]*N
for i in range(1,N+1):
  c[i-1]=(A*i)//B-A*(i//B)

print(max(c))

Submission status: Runtime Error

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

print(min(b-1,n))

Submission status: Runtime Error

Solution code:
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

a,b,n = inL()

i = 0

l = [0]*(b+1)
for i in range(1,min(b,n)+1):
    l[i] = int(a*i/b)-a*int(i/b)


print(max(l))

Submission status: Runtime Error

Solution code:
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

a,b,n = inL()

i = 0

l = [0]*b
for i in range(1,min(b,n)+1):
    l[i] = int(a*i/b)-a*int(i/b)
    #if (q <= p):
        #break

print(max(l))

Submission status: Runtime Error

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

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(max(ans))

Submission status: Runtime Error

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

ans=[]

for i in range(B):
    
    ans.append(int(a*i/b) - a * int(i/b))

print(min(ans))

Submission status: Runtime Error

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

if B > N:
  ans = math.floor(A * N / B) - A * math.floor(N // B)
else:
  ans = math.floor(A * (B - 1) / B) - A * math.floor(N // (B - 1))
  
print(ans)

Submission status: Runtime Error

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

if B > N:
  ans = (A * N) // B - A * (N // B)
else:
  ans = (A * (B - 1)) // B - A * (N // (B - 1))
  
print(ans)

Submission status: Runtime Error

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

y = 0

for x in range(1,n+1):
    if x%b!=0:
        temp = ((a*x)//b) - a*(x//b)
    else:
        temp = 0
    if y < temp:
        y = temp
        ans = x
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
ans = 0

a = [0]*N

for x in range(1,N+1):
    # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
    a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

print(max(a))

Submission status: Runtime Error

Solution code:
import math

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

if N < B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*N/B) - A*math.floor(N/B)
    ans = max(temp1, temp2)

if N > B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
    ans = max(temp1, temp2)

print(ans)

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
max=0
for i in range(1,n+1):
    if a%b*i%b!=0:
        if a%b*i%b<a%b
            ans=a*i//b -a*(i//b)
            if max<ans:
                max=ans

print(max)

Submission status: Runtime Error

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
baketu = [0]*(n+1)
for i in range(1,n+1):
    dum = math.floor(a*i/b)-(a*math.floor(i/b))
    if baketu[dum] >= 1:
        break
    baketu[dum] += 1
    ans = max(ans,dum)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
def f(a,b,x):
    return int(a*x//b-a*(x//b))
res = [-float('inf')]*3
res[0] = f(a,b,n)
if n >= b:
    res[1] = f(a, b, b)
    if n > b:
        res[2] = f(int(a,b,n//b*b))
print(max(res))

Submission status: Runtime Error

Solution code:
def main():  
  a, b, n = map(int, input().split())
  q = n//b
  ans = [-1]+[-1]*n
  k = b-1
  for i in range(q):
    ans[k]=((a*k)//b - a*(k//b))
    k = k+b
  ans[n]=((a*n)//b - a*(n//b))
  maxi = max(ans)
  print(ans.index(maxi))
  
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import math
a, b, n = map(int, input().split())
 
 
def calc(a, b, n):
    return int(math.floor((a * n)/b) - (a * math.floor(n/b)))
 
nn = min(n, b - 1)
print(calc(a, b, nn)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(10**12)
a,b,n = list(map(int,input().split()))

ans = 0
for i in range(1,n+1):
    result = math.floor(a*i/b) - a * math.floor(i/b)
    result = int(result)
    ans = max(ans, result)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(f(np.arange(N+1)))))

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N, = map(int, input().split())
def f(x):
    global A, B
    return np.floor(A*x/B)-A*np.floor(x/B)
x = np.arange(N+1)
print(int(np.max(f(np.arange(N+1)))))

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations_with_replacement, compress
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, M, Q = LI()
    abcd = [LI() for _ in range(Q)]
    ans = 0

    for A in combinations_with_replacement(range(1, M + 1), N):
        tmp = 0
        for (a, b, c, d) in abcd:
            tmp += d if (A[b-1] - A[a-1] == c) else 0
        ans = max(ans, tmp)
    print(ans)


main()

Submission status: Runtime Error

Solution code:
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations_with_replacement, compress
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    N, M, Q = LI()
    abcd = [LI() for _ in range(Q)]
    ans = 0

    for A in combinations_with_replacement(range(1, M + 1), N):
        tmp = 0
        for (a, b, c, d) in abcd:
            tmp += d if (A[b-1] - A[a-1] == c) else 0
        ans = max(ans, tmp)
    print(ans)


main()

Submission status: Runtime Error

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

def f(x):
    return math.floor(A * x / B) - A * math.floor(x / B)

if B - 1 <= N:
    ans = f(B - 1)
else:
    ans = f(N)
print(ans)

Submission status: Runtime Error

Solution code:
A, B, N = list(map(int,input().split()))
if B - 1 <= N:
    ans = f(B - 1)
else:
    ans = f(N)
print(ans)

Submission status: Runtime Error

Solution code:
from math import floor

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

func = []
max = 0

for x in range(1, n+1):
#    if floor(a*x/b) < a*floor(x/b):
#        break
    func.append(floor(a*x/b) - a*floor(x/b))
    if max < func[-1]:
        max = func[-1]
    if x > 2:
        diff = func[-1] - func[-2]
    if diff < 0:
        break

print(max)

Submission status: Runtime Error

Solution code:
from math import floor

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

func = [0]*(n+1)
max = 0

for x in range(1, n+1):
    func[x] = floor(a*x/b) - a*floor(x/b)
    if max < func[x]:
        max = func[x]
print(max)

Submission status: Runtime Error

Solution code:
import math
import collections
def f(a,b,x):
    return math.floor((a*x)/b) - a*math.floor(x/b)
a,b,n=map(int, input().split())
dd = collections.defaultdict(int)

print(f(a,b,min(b-1,x)))

Submission status: Runtime Error

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

def f(a,b,x):
    return (a*x)//b - a*(x//b)

print(f(min(b-1,n)))

Submission status: Runtime Error

Solution code:
import sys
def main():
    A,B,N=tuple(map(int,sys.stdin.readline().split()))
    L=min([B-1,N])
    print(max(list(map(lambda c:(A*c)//B,list(range(1,L+1))))))
if __name__=='__main__':main()

Submission status: Runtime Error

Solution code:

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

x = min(B - 1, N)
ans = int(a * x / b)
print(ans)

Submission status: Runtime Error

Solution code:
A, B, N = [int(i) for i in input().split(' ')]

if B > N:
    x = N
else:
    X = B - 1

m = int(A * x / B) - A * int(x / B)

print(m)

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
import math
def f(x):
    return math.floor(A*x/B) - A*math.floor(x/B)

ans = []
for i in list(reversed(range(1, N//B+1)))[:100]:
    ans.append(f(B*i-1))
ans.append(f(N))
ans.append(f(1))
#print(f(N))
print(max(ans))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
score=0
if (n<b):
    print( int(a*n/b))
elif(b＝＝１):
    print(0)
else:
    c = int(n/b)
    score = 0
    for i in range(1,c+1):
        n_ = b*i-1
        t = int(a*n_/b)-a*int(n_/b)
        score = max(score,t)
    t = int(a*n/b)-a*int(n/b)
    score = max(score,t)
    print(score)

Submission status: Runtime Error

Solution code:

from sys import stdin
input = stdin.readline

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

if b > n :
    for i in range(n+1):
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
       
        
else:
    for i in reversed(range(n+1)):
        c += 1
        tmp = int((a * i) / b)  - a * int(i/b) 
        if b > 1:
            if i % (b-1) == 0 :
                maxpoint = max(tmp,maxpoint)
                print(maxpoint) 
                exit()
        elif b == 1:
            print(0)
            exit()
        maxpoint = max(tmp,maxpoint)

print(maxpoint)

Submission status: Runtime Error

Solution code:

from sys import stdin
input = stdin.readline

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

if b > n :
    for i in range(n+1):
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
        print(0)
        
else:
    for i in reversed(range(n+1)):
        c += 1
        tmp = int((a * i) / b)  - a * int(i/b) 
        if b > 1:
            if i % (b-1) == 0 :
                maxpoint = max(tmp,maxpoint)
                print(maxpoint) 
                exit()
        elif b == 1:
            print(0)
            exit()
        maxpoint = max(tmp,maxpoint)

print(maxpoint)

Submission status: Runtime Error

Solution code:

from sys import stdin
input = stdin.readline

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

maxpoint = 0

for i in reversed(range(n+1)):
    tmp = int((a * i) / b)  - a * int(i/b) 
    if i % (b-1) == 0 and b > 1:
        print(tmp) 
        exit()
    maxpoint = max(tmp,maxpoint)

print(maxpoint)

Submission status: Runtime Error

Solution code:
from sys import stdin
input = stdin.readline

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

maxpoint = 0

for i in reversed(range(n+1)):
    if i % (b-1) == 0:
        tmp = int((a * i) / b)  - a * int(i/b) 
        maxpoint = max(tmp,maxpoint)
        print(maxpoint)
        exit()
    tmp = int((a * i) / b)  - a * int(i/b) 
    maxpoint = max(tmp,maxpoint)

print(maxpoint)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
c = [0]*(n+1)
for x in range(n+2):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
c = [0]*(n+1)
for x in range(n+1):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
current = 0
c = [0]*(n+1)
for x in range(n+1):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
current = 0
c = [0]*(n+1)
for x in range(1,n+1):
  c[x]= (a*x)//b - a*(x//b)
print(max(c))

Submission status: Runtime Error

Solution code:
a,b,n = list(map(int, input().split()))
def f(x):
    return a*x//b - a*(x//b)

left=1
right=n
for _ in range(100):
    delta=(right-left)/3
    midl=left+delta
    midr=midl+delta
#    print(f'left={left} midl={midl} midr={midr} right={right}')
    if f(midl)>f(midr):
        right=midr
    else:
        left=midl
print(max(f(int(midl)),f(min(int(midl)+1),n)))

Submission status: Runtime Error

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

As = [[i] for i in range(1, m+1)]

while len(As[0]) != n:
    current = As.pop(0)
    for i in range(current[-1], m+1):
        As.append(current+[i])

inputs = []

for _ in range(q):
    inputs.append(list(map(int, input().split())))

answer = 0

for A in As:
    local_ans = 0
    for i in inputs:
        if A[i[1]-1]-A[i[0]-1] == i[2]:
            local_ans += i[3]
    answer = max(answer, local_ans)

print(answer)

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
if N>=B-1:
  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:
a,b,n=map(int,input().split())
import math

ans1=math.floor(a*n/b)-a*math.floor(n/b)
ans2=math.floor(a*(b-1)/b)
if n=<(b-1):
  print(ans1)
else:
  print(max(ans1,ans2))

Submission status: Runtime Error

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

def calc(x):
    return ((A * x) // B) - A * (x // B)

prit(max(calc(N), calc(B - 1)))

Submission status: Runtime Error

Solution code:
x=int(input())

for i in range(1,120):
    for j in range(-120,120):
        if ((i**5)-(j**5))==x:
            print(i, j)
            exit()

Submission status: Runtime Error

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

x = N
if B < N :
    x = int(N / B) * B - 1
else if B == N :
    x -= 1

val = int(A * x / B) - A * int(x / B)

print(val)

Submission status: Runtime Error

Solution code:
import math
import random
A, B, N = map(int, input().split())
def floor(x):
  return math.floor(x)
x = list(range(N + 1))

max = floor( A* random.randrange(N) / B) - A * floor(random.randrange(N) / B)
print(max)

Submission status: Runtime Error

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

if n < b:
    x = n
    score = math.floor(a*x/b) - a * math.floor(x/b)
    print(score)
    
else:
    x = b-1
    score = math.floor(a*x/b) - a * math.floor(x/b)
    print(max_score)

Submission status: Runtime Error

Solution code:
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
n=temp[2]
if (b-1)<n :
  x=(b-1)
else :
  x=n
v=((a*x)//b)-(a*(x//b))
print v

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N = map(int, input().split())
x = np.arange(0,N+1,1)

num = (A*x/B)//1 - A * ((x/B)//1)

print(int(np.max(num)))

Submission status: Runtime Error

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

print(min(b-1, n))a,b,n = map(int, input().split())

print(min(b-1, n))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
max = -1
max_x = -1
for x in range(N):
    diff = math.floor(A * x / B) - A * math.floor(x / B)
    if diff > max:
        max_x = x
        max = diff

print(max_x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,n = map(int,input().split())
c = n // b * b
ans=0
if n > b - 1:
    ans = math.floor(a * c / b) - a * math.floor(c / b)

else:
    #for i in range(n):
        #print(i+1)
        #print(math.floor(a * (i+1) / b) - a * math.floor((i+1) / b))
        #if math.floor(a * (i+1) / b) - a * math.floor((i+1) / b) > ans:
        #    ans = math.floor(a * (i+1) / b) - a * math.floor((i+1) / b)
    ans = math.floor(a * n / b) - a * math.floor(n / b)
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

if b <= 10**6
    maxVal = 0

    for i in range(b):
        if i > n:
            break
        val = math.floor(a*i/b)-a*math.floor(i/b)
        if val > maxVal:
            maxVal = val

    print(maxVal)
elif n > b:
    print(a-1)
elif n == b:
    m = n - 1
    print(math.floor(a*m/b)-a*math.floor(m/b))
else:
    print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Runtime Error

Solution code:
A, B, N = [int(v) for v in input().strip().spilt(" ")]

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

Submission status: Runtime Error

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

def calcM(A, B, x):
        return math.floor(A / B * x) - A * math.floor(x / B)    

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    if B < N:
        max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N-B, N+1))), default=N)
    # print('max_x:', max_x)
    return max(maxM, calcM(A, B, max_x))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
c = max(b-1, n)
parint(int(a*c/b))

Submission status: Runtime Error

Solution code:
import math

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

a=N//B

if a==0:
    x=N
    

elif N%B==0:
    x=a*B-1
else:
    x=B*a-1

while math.floor(A*x/B)==math.floor(A*(x-1)/B):
    x=x-1
    if x==1:
        break
ans=math.floor(A*x/B)-A*math.floor(x/B)
ans=max(ans)

print(ans)

Submission status: Runtime Error

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
#for i in range(N//2, N + 1):
    #if(floor(i) > max):
        #max = floor(i)
max = max(floor(N), floor(B-1))

print(max)

Submission status: Runtime Error

Solution code:
from sys import stdout,stdin
from queue import Queue
from collections import defaultdict
import math
a = int(input())
b = int(input())
n = int(input())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
stdout.writelines(str(ans) + '\n')

Submission status: Runtime Error

Solution code:
from sys import stdout
from queue import Queue
from collections import defaultdict
import math
a = int(input())
b = int(input())
n = int(input())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
stdout.writelines(str(ans) + '\n')

Submission status: Runtime Error

Solution code:
import math
from sys import stdout
a = int(input())
b = int(input())
n = int(input())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
stdout.writelines(str(ans) + '\n')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
def floor(a,b,c):
  for i in range(c+1):
    d=(a*i/b)//1-a*((i/b)//1)
    for j in range(c+1):
      e=(a*j/b)//1-a*((j/b)//1)
      if e>d:
        M=e
  return int(M)
print(floor(a,b,c))

Submission status: Runtime Error

Solution code:
import math
def equation(a,b,n):
  return math.floor((a*x)/b)-A*math.floor(x/B)
d,e,f = map(int,input().split())
X = equation(d,e,f)
Y = equation(d,e,e-1)
print(max(X,Y))

Submission status: Runtime Error

Solution code:
a,b,n=map(int(input().split())
if b-1<=n:
  x=b-1
  print(int(a*x/b)-a*int(x/b))
else:
  x=n
  print(int(a*x/b)-a*int(x/b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
for i in range(b-1):
  tmp = (a*i) // b - a*(i // b)
  ans = 0
  ans = max(tmp,ans)
print(ans)

Submission status: Runtime Error

Solution code:
import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b:
    #print(math.floor(a*n/b))
    exit()
for i in range(math.floor(n/b)):
    t = math.floor(a*(b(i+1))/b)-a*i
    #print("a")
    if cnt <= t:
        cnt=t
            
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import scipy
import itertools

def score(arr):
    hoge = 0
    for ai,bi,ci,di in zip(a, b, c, d):
        if arr[bi-1]-arr[ai-1] == ci:
            hoge += di
    return hoge

def dfs(arr):
    if len(arr) == n:
        return score(arr)
    last = arr[-1] if len(arr) > 0 else 0
    res = 0
    for i in range(last, m+1):
        arr.append(i)
        res = max(res, dfs(arr))
        arr.pop()
    return res

def solve():
    global a, b, c, d, n, m, q
    n, m, q = map(int, input().split())
    a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
    for i in range(q):
        a[i], b[i], c[i], d[i] = map(int, input().split())
    print(dfs([]))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    # num = N//B

    # score = 0
    # for x in range(1, N+1):
    #     tmp = int(A*x/B) - A*int(x/B)
    #     if score <= tmp:
    #         score = tmp
    # print(score)

    import numpy as np

    arr = np.arange(N)
    arr = np.modf(arr/B)[0]
    print(int(max(arr*A)))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
if b>=n:
	l=a*n//b
elif b<n:
  for i in (b,n):
    d=a*i//b-a*(i//b)
    if l==null:
      l=d
    if d>l:
      l=d
print(l)

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
if b>=n:
	l=a*n//b
elif b<n:
  for i in (b,n):
    d=a*i//b-a*(i//b)
    if d>l or l==null:
      l=d
print(l)

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
if b>n:
	l=a*n//b
elif b<n:
  for i in (b,n):
    d=a*i//b-a*(i//b)
    if d>l or l==null:
      l=d
print(l)