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: Time Limit Exceeded

Solution code:
import sys
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = 0

if N < B - 1:
    ans = math.floor(A * N / B) - A * math.floor(N / B)
else:
    c = B - 1
    while c <= N:
        t = math.floor(A * c / B) - A * math.floor(c / B)
        ans = max(ans, t)
        c += B

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
# s=n//b
nmax = (a*n)//b - a*(n//b)
# for i in range(1,s+1):
#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
b_n = b
b_nn = 0
while b_n <= n:
    x = b_n -1
    t = (a*x)//b - a*b_nn
    if t > nmax:
        nmax = t
    b_n += b
    b_nn +=1
print(nmax)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s = input().split()
a = int(s[0])
b = int(s[1])
n = int(s[2])

l = list()

ans = 0
for x in range(n):
    pre = a*(x+1)//b - a*((x+1)//b)
    if ans < pre:
        ans = pre

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
x=0
max=math.floor(A*x/B)-A*math.floor(x/B)
while(x<N):
    x+=1
    if max<(math.floor(A*x/B)-A*math.floor(x/B)):
        max=(math.floor(A*x/B)-A*math.floor(x/B))
print(max)

Submission status: Time Limit Exceeded

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

if N > 10000:
    for x in range(N+1, int(N/2), -1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
else:
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

l = []
for i in range(1, N+1):
  l.append((A*i//B) - A*(i//B))
    
print(max(l))

Submission status: Time Limit Exceeded

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

ans = -10**12
for x in range(1,n+1):
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
for i in range(10000000):
    if b[2]-i <0:
        break
    check = math.floor((b[0]*(b[2]-i))/b[1]) - b[0]*math.floor((b[2]-i)/b[1])
    if check > ans:
        ans=check
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
import math
ans=0
d=min(n,b)
e=b-1
for i in range(d):
    ans=max(ans,math.floor(a*i/b)-a*math.floor(i/b))
if b>d:
    print(math.floor(a*d/b)-a*math.floor(d/b))
else:
    print(math.floor(a*e/b)-a*math.floor(e/b))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res >= m:
        m = res
    else:
        break

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math


A, B, N = map(lambda x: int(x), input().split(" "))

result = 0
for i in range(0, N+1, B):
    if i <= 1:
        continue
    i -= 1
    temp = math.floor(A*i/B) - A*math.floor(i/B)
    result = max(result, temp)
temp = math.floor(A*N/B) - A*math.floor(N/B)
result = max(result, temp)

print(result)

Submission status: Time Limit Exceeded

Solution code:

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

Submission status: Time Limit Exceeded

Solution code:
import math
li = list(map(int, input().split()))
maxn=0
for x in range(1, li[2] + 1):
  temp=0
  a = math.floor(li[0] * x / li[1])
  b = math.floor(x / li[1])
  temp = a - a * b
  if temp > maxn:
    maxn = temp
print(maxn)

Submission status: Time Limit Exceeded

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

a = 0
ans = 0

for i in range(N//2,N+1):
  a = int(A*i/B) - A*int(i/B)
  if ans < a:
    ans = a
  
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
ABN = input().split()
A = int(ABN[0])
B = int(ABN[1])
N = int(ABN[2])

answer = 0
temp = 0

for x in range(N+1):
    temp = (A*x)//B - A * (x//B)

    if answer < temp:
        answer = temp

print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def solve(a, b, n):
    ans_arr = []
    for i in range(1, n+1):
        ans_arr.append(math.floor(a * i / b) - a * math.floor(i / b))
    return max(ans_arr)

if __name__ == "__main__":
    a, b, n = map(int, input().split(' '))
    print(solve(a,b,n))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = 0
for x in range(1, N + 1):
    if x < B:
        n = floor(x * AdB)
        if n > m:
            m = n
    else:
        n = floor(x * AdB) - A * floor(x / B)
        if n > m:
            m = n
print(m)

Submission status: Time Limit Exceeded

Solution code:
import math
l = list(input().split(" "))
a = int(l[0])
b = int(l[1])
n = int(l[2])
def f(x):
  return math.floor(x)
c = f(a/b) - a*f(1/b)
for i in range(2,n+1):
  d = f(a*i/b) - a*f(i/b)
  if c >= d:
    c = c
  else:
    c = float(d)
print(int(c))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in range(1, N+1):
  i = int(A*x/B) - A * int(x/B)
  mlist.append(i)

print(max(mlist))

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
max = 0
i = 1
while True:
  x = i * B -1
  if x > N:
    if i == 1:
      x = N
    else:
      break
  k = int(((x / B) - (x // B)) * A)
  if k > max:
    max = k
  i +=1
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

k = (n + 1) // b

ans = 0
for x in range(max(0, k * b - 1), n + 1):
    ans = max(ans, f(x))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B, N = MAP()

left, right = 0, N

def f(x):
    return int(A*x/B) - A*int(x/B)


while right-left > 1:
    mid1 = (left + right)*1// 3
    mid2 = (left + right)*2// 3

    if f(mid1) < f(mid2):
        if left == mid1:
            break
        left = mid1
    else:
        if right == mid1:
            break
        right = mid2

ans = f(left)
for i in range(left, right+1):
    ans = max(ans, f(i))
print(ans)
# ans = 0
# # whilefor i in range(1, N+1):
# #     ans = max(ans, f(i))
# # print(ans)

# x = N//2
# if f(x) <= f(x)
# direc = "R"

Submission status: Time Limit Exceeded

Solution code:

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,n+1):
        temp = int(a*x/b) - a * int(x / b)
        mx = max(mx,temp)
    print(mx)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for x in range(1,N+1):
  C = x/B
  Y = int(A*C)-A*int(C)
  a.append(Y)

answer = max(a)

print(answer)

Submission status: Time Limit Exceeded

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

def floor(x):
  return int(x//1)

list = []
for x in range(N+1):
  list.append(floor((A*x)/B)-(A*floor(x/B)))
print(max(list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
for i in range(100000000):
    if b[2]-i <0:
        break
    check = math.floor((b[0]*(b[2]-i))/b[1]) - b[0]*math.floor((b[2]-i)/b[1])
    if check > ans:
        ans=check
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def floor(x):
    import math
    return math.floor(x)

if __name__ == '__main__':
    a, b, n = map(int, input().split())
    m = 0
    for x in range(1, n+1):
        p = floor(a*x/b) - a*floor(x/b)
        x += 1
        if m <= p:
            m = p
    print(m)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
def floor(x):
    return (a*x)//b - a*(x//b)
ans = 0
if b <= n: 
    for i in range(b-1,n+1):
        ans = max(ans,floor(i))
        #print(floor(i))
    print(ans)
else:
    print(floor(n))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(N + 1):
  s = math.floor(A * i / B) - A * math.floor(i / B)
  l.append(s)
print(max(l))

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split())
ma = -1
for x in range(n, -1, -1):
    tmp = math.floor(a*x/b) - a*math.floor(x/b)
    if ma < tmp:
        ma = tmp
print(ma)

Submission status: Time Limit Exceeded

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

p=0
for i in range(n):
    c=(a*(i+1))//b
    d=((i+1)//b)*a
    q=c-d
    if q>p:
        p=q
    if q<p:
        break

print(p)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans = 0
for x in range(n//2, n+1):
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    #print(tmp)
    if tmp > ans:
        ans = tmp

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = map(int, input().split())
y = 0
lst = []
for i in range(1, n+1):
    y = math.floor(a*i/b) - a * math.floor(i/b)
    lst.append(y)

print(max(lst))

Submission status: Time Limit Exceeded

Solution code:
#abc 165
# d
a,b,n = map(int,input().split())
nmax = 0

for i in range(0,min(b,n+1)):
    ni = int(a*i/b)
    if ni > nmax:
        nmax = ni
print(nmax)

Submission status: Time Limit Exceeded

Solution code:
import math

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

m = 0

for x in reversed(range(1,n+1)):
    if m > a*x/b:
        break
    else:
        y = math.floor(a*x/b) - a * math.floor(x/b)
        if m < y:
            m = y

print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import math
A, B, N = map(int, input().split())
list1 = []
for x in range(N+1):
    list1.append(math.floor(A*x/B) - A*math.floor(x/B))
list1.sort(reverse=True)
print(list1[0])

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
c = 0
for x in range(1, N+1):
    a = math.floor(A*x/B) - A * math.floor(x/B)
    if a < c:
        break
    c = a
print(c)

Submission status: Time Limit Exceeded

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

for x in range(n+1):
    li.append(math.floor((a*(x))/b) - a * math.floor(x/b))
print(max(li))

Submission status: Time Limit Exceeded

Solution code:
import math
ABN=input().split()
A=int(ABN[0])
B=int(ABN[1])
N=int(ABN[2])
max=0
for i in range(1,N+1):
    tmp=math.floor(A*i/B)-A*math.floor(i/B)
    if(tmp>max):
        max=tmp
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math


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

    ans = 0

    for i in range(N, 1, -1):
        tmp = math.floor(A * i / B) - A * math.floor(i / B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
max=0
def floor(a,b,x):
    return int(a*x/b)
for i in range(n+1):
    if max < floor(a,b,i)-a*floor(1,b,i):
        max = floor(a,b,i)-a*floor(1,b,i)
print(max)

Submission status: Time Limit Exceeded

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

tmp_pre = 0
for i in range(1, N+1):
  tmp = math.floor(A*i/B) - A*math.floor(i/B)
  if tmp > tmp_pre:
    tmp_pre = tmp
print(int(tmp_pre))

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(1, N+1):
    p = int((A*x)/B) - A*int(x/B)
    if p<ans:
        break
    ans = p

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = list(map(int,input().split()))
x = 1
temp = 0
res = 0

for i in range(n):
    temp = math.floor((a*x)/b) - a * math.floor(x/b)
    if res < temp:
        res = temp
    x += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:

s = input().split()
a = int(s[0])
b = int(s[1])
n = int(s[2])

l = list()

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


print(max(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def input_number():
    return int(input())

def input_1line_list(number_of_input):
    return [input() for i in range(number_of_input)]

def input_1line():
    return map(int, input().split())

# def print_unique_length(input_list):
#     print(len(set(input_list)))

def main():
    a, b, n = input_1line()
    ans = 0
    for i in range(n+1):
        ans = max(ans, math.floor(a*i/b) - a*math.floor(i/b))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

num = 0
max_num = 0

for i in range(1, n+1):
    num = math.floor(a*i/b) - a * math.floor(i / b)
    max_num = max(max_num, num)
print(max_num)

Submission status: Time Limit Exceeded

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

ans = [(a*i//b) - a*(i//b) for i in range(1, n+1)]

print(max(ans))

Submission status: Time Limit Exceeded

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


for i in range(N):
    b = int(A*(i+1)/B)-A*(int((i+1)/B))
    ans.append(b)

list.sort(ans)
print(ans[-1])

Submission status: Time Limit Exceeded

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

result = []
for i in range(1, n+1):
    result.append(math.floor(a * i / b) - a * math.floor(i / b))

print(max(result))

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = 0
test = 0
cnt = 1
while n >= cnt:
    test = int((a * cnt) / b) - (a * int((cnt / b)))
    if test > ans:
        ans = test
    cnt += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N =map(int,input().split())
ans =0
for x in range(1,N+1):
  num = math.floor(A*x/B) - A * math.floor(x/B)
  if num > ans:
    ans = num

print(ans)

Submission status: Time Limit Exceeded

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

from math import floor
def func(x):
    return floor(A*x/B) - A * floor(x / B)

ans = -10**12
for i in range(N+1):
    t = func(i)
    if ans <= t: ans = t
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys


a,b,n = (int(i) for i in input().split())


ans =0

for i in range(1,n+1):
    temp = a*i//b-a*(i//b)
    if temp > ans:
        ans = temp


print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
# s=n//b
nmax = (a*n)//b - a*(n//b)
# for i in range(1,s+1):
#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
b_n = b
while b_n <= n:
    x = b_n -1
    t = (a*x)//b - a*(x//b)
    if t > nmax:
        nmax = t
    b_n += b
print(nmax)

Submission status: Time Limit Exceeded

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

for x in range(N+1):
    floor = int(A*x / B) - A * int(x/B)
    if x == 0:
        max = floor
    else:
        if floor >= max:
            max = floor
            
print(max)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # input()
    A,B,N=map(int, input().split())

    max=0
    for x in range(N+1):
        ans=int(A*x/B)-A*int(x/B)
        if ans > max:
            max=ans

    print(max)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
def floor(x):
    return (a*x)//b - a*(x//b)
ans = 0
p = b-1 if b < n else 1 
for i in range(p,n+1):
    ans = max(ans,floor(i))
    #print(floor(i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = 0
for x in range(1,n+1):
    f = a * x // b
    f2 = x // b

    if ans <= f - a * f2:
        ans = f - a * f2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

def f(n):
    return (a*n)//b-a*(n//b)

ans=0
pre=0
for i in range(1,x+1):
    pre=f(i)
    #print(ans,pre)
    if ans<f(i):
        ans=pre

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

val = (int(A * i / B) - A * int(i / B) for i in range(1, N+1))
print(max(val))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
ans2 = (A*N)//B - (A*(N//B))
for i in range(B-1, N, B):

    ans2 = max(ans2, (A*i)//B - (A*(i//B)))
print(ans2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_v = 0
for x in range(min(B+1, N+1)):
    v = math.floor(A*x/B) - A*math.floor(x/B)
    if max_v < v:
        max_v = v
print(max_v)

Submission status: Time Limit Exceeded

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

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = [int(i) for i in input().split()]

x = 1
max_ = -1
while(x <= n):
    max_ = max(a * x // b - a * (x // b), max_)
    x += 1
print(max_)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
c =0
for i in range(n+1):
    p =i % b 
    P = a*p//b
    if P > c:
        c = P
print(c)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y
ans = func(1)
i = 1
while True:
    i += 1
    if i > n:
        print(ans)
        break
    elif ans > func(i):
        print(ans)
        break
    elif ans <= func(i):
        ans = func(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#


def main():
    a, b, n = map(int, input().split(" "))
    fac = 0
    for i in range(n + 1):
        j = i // b
        if j == 0:
            if fac < i:
                fac = i
        else:
            break
    ans = a * fac // b - a * (fac // b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = 0
for i in range(1, min(n+1, b+1)):
    s = int(((a*i)/b) // 1 - a * ((i/b)//1))
    if s > ans:
        ans = s
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
m = 0
for n in range(N+1):
    r = math.floor(A*n/B)-A*math.floor(n/B)
    if r>m:
        m = r

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math
s = list(map(int,input().split()))
n=s[0]
m=s[1]
q=s[2]
x=0
for i in range(1,q+1):
    re=math.floor(n*i/m)-math.floor(i/m)*n
    if x<re:
        x=re
print(x)

Submission status: Time Limit Exceeded

Solution code:

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

dammy=[]
for x in range(N+1):
    dammy.append((A*x)//B - A * int(x/B))

print(max(dammy))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
ans,point = 0,0
for i in range(1,N+1):
    amari = i%B
    Aamari = A*amari
    point = math.floor(Aamari/B)
    ans = max(ans,point)
print(ans)

Submission status: Time Limit Exceeded

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

span = range(1, N+1)
result = 0

for i in span:
  answer = (A * i) // B - A * (i // B)
  if answer > result:
    result = answer

print(result)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = 0
for x in range(0, n+1):
    flour = int((a*x)/b) - a*int(x/b)
    if flour >= ans:
        ans = flour
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C0,C1,C2,C3)
    if C0==C:
        ed=mid2
    elif C1==C:
        ed=mid2
    elif C2==C:
        st=mid1
    elif C3==C:
        st=mid1
if ed-st==2:
    C=max(main(st),main(st+1),main(ed),C)
print(C)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(N + 1):
    a = math.floor(A * i / B) - A * math.floor(i / B)
    ans.append(a)

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
S = 0
for i in range(N+1):
    while S < max(S,(A*i)//B - A * (i//B)):
        S = max(S,(A*i)//B - A * (i//B))
print(S)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(1,n+1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=[int(x) for x in input().split()]

ma=0
for i in range(1,n+1):
    ma=max(ma,(i*a)//b-a*(i//b))
print(ma)

Submission status: Time Limit Exceeded

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

x = 0
#for x in range( int( a * n / b ) + 2 ):
while True:
    f_x = int( a * x / b ) - a * int( x / b )
    if x == 0 or f_max < f_x:
        f_max = f_x
    if int( a * x / b ) == int( a * n / b ):
        break
    x = x + 1

print( f_max )

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
ans2 = 0
for i in range(B-1, N+B, B):
    if i >= N:
        i = N
    ans2 = max(ans2, (A*i)//B - (A*(i//B)))

print(ans2)

Submission status: Time Limit Exceeded

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

for x in range(1,N+1):
  Y = int(A*x/B)-A*int(x/B)
  a.append(Y)

answer = max(a)

print(answer)

Submission status: Time Limit Exceeded

Solution code:
A,B,N= map(int, input().split())
ans = 0
for i in range(N+1):
    d = (int((A*i)/B) - A *int(i/B))
    if ans < d:
        ans = d
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
a,b,n = map(int,input().split())

ans = 0
tmp = min(b, n)
for x in range(int(pow(n, 0.5)) + 1, n+1):
    #print(x)
    tmp1 = (a * x) // b - (a * (x // b))
    if tmp1 >= ans:
        ans = tmp1
print(ans)

Submission status: Time Limit Exceeded

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

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

print(maxim)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
ans = 0
for i in range(1,N+1):
	num = math.floor((A*i)/B) - A * math.floor(i / B)
	if ans < num:
		ans = num
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def floor(A,B,x):
    return int(A*x/B)-A*int(x/B)

A,B,N =map(int,input().split())
ans = 0
for i in range(0,N+1):
    ans =max(ans,floor(A,B,i))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int, input().split())
g=0
for i in range(n+1):
    #print('a')
    t=(a*i)//b-a*(i//b)
    #print(t)
    if i==0:
        m=t
        g=0
    else:
        if t==max(m,t):
            m=t
            g=i
print(m)

Submission status: Time Limit Exceeded

Solution code:
import math


def solve():
    A, B, N = map(float, input().split())
    ans = 0

    for i in reversed(range(max(1, int(N)-10000, int(N) + 1))):
        ans = max(math.floor(A * i / B) - A * math.floor(i / B), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
Ymax=0
for i in range(N):
  x = i+1
  Y = int(float(A)*float(x)/float(B)) - A * int(float(x)/float(B))
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
ans = -float("inf")
for x in range(n):
    num = math.floor(a*(x+1)/b) - a*(math.floor((x+1)/b))
    if num > ans:
        ans = num
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

def f(a, b, x):
    return math.floor(a*x/b) - 5 * math.floor(x/b)

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

for i in range(b):
    if i > n:
        break
    elif f(a, b, i) > max:
        max = f(a, b, i)

print(max)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
s=n//b
nmax = (a*n)//b - a*(n//b)
for i in range(1,s+1):
    x = b*i-1
    t = (a*x)//b - a*(x//b)
    if t > nmax:
        nmax = t
print(nmax)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
A,B,N  = map(int,input().split())
num = 0
for x in range(0,N+1)[::-1]:
    tmp = floor((A*x)/B) - (A * floor(x/B))
    if num < tmp:
        num = tmp
print(num)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
x_kouho=[]
count=1
while count<=n//b:
  x_kouho.append(b*count-1)
  count+=1
if not x_kouho:
  x_kouho.append(n)

res=0
for i in range(0,len(x_kouho)):
  keep=x_kouho[i]
  kept=(a*keep)//b-a*(keep//b)
  if kept>res:
    res=kept
print(res)

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
ls = []
for x in range(0, N+1):
    a = math.floor(A*x/B) - A * math.floor(x/B)
    ls.append(a)

print(max(ls))