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 math

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

m = -1
c = 0
for x in range(0,min(b,n)+1):
    c = math.floor(a*x/b)-a*math.floor(x/b)
    #print('a:',c)
    if c >= m:
        m=c
    else:
        break
if n>b:
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        #print('b:',c)
        if c >= m:
            m=c
        else:
            break
print(m)

Submission status: Time Limit Exceeded

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

import math

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

print(ans)

Submission status: Time Limit Exceeded

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

print(mmax)

Submission status: Time Limit Exceeded

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

x = list()
for i in range(n):
  y = int(a*(i+1)/b) - a*int((i+1)/b)
  x.insert(bisect.bisect_left(x,y),y)

print(x[-1])

Submission status: Time Limit Exceeded

Solution code:
#d
A,B,N=map(int,input().split())
b=[]
for i in range(1,(N//B)+1):
    b.append(i*B-1)
b.append(N)
a=0
for x in b:
    p=(A*x)//B-A*(x//B)
    if p>a:
        a=p
print(a)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
def fnc(x,y):
    return math.floor(x/y)
i=1
list=[0]
list=[fnc(a*i,b)-a*fnc(i,b) for i in range(n+1)]
print(max(list))

Submission status: Time Limit Exceeded

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

def func(A, B, x):
  return (A*x)//B - A * (x//B)

if(N>B):
  for i in reversed(range(N-B, N+1)):
    maxlist.append(func(A,B,i))
else:
  for i in reversed(range(N+1)):
    maxlist.append(func(A,B,i))
  
print(max(maxlist))

Submission status: Time Limit Exceeded

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

output = 0
for x in range(1, n + 1):
    if x % (a * b) == 0:
        break
    buf = (a*x//b) - a*(x//b)
    if buf > output:
        output = buf

print(output)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
x=0
while int(x//b)==0 and x<=n:
    x+=1
print((int((a*(x-1))//b) - a*(int((x-1)//b))))

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):
    ans=max(ans,math.floor((i%b)*a/b))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

m = 0

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

Submission status: Time Limit Exceeded

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

res = 0
if N < B:
    res = (A * N) // B
else:
    res = ((A * (B - 1)) // B) - (A * ((B - 1) // B))
    i = B
    while i < N + 1:
        a = ((A * i) // B) - (A * (i // B))
        if res <= a:
            res = a
        else:
            break
        i += B

print(res)

Submission status: Time Limit Exceeded

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

if N<B:
  L = N
else:
  L = B

for i in range(L):
  x = i+1
  Y = int(A*x//B) - A*(x//B)
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
    X = ((A*i) // B)
    Y = A * (i // B)
    if biggest < (X - Y):
        biggest = X - Y

print(biggest)

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):
    if x > b:
        break
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    #print(x, tmp)
    if tmp > ans:
        ans = tmp
 
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_v = 0
for x in range(n+1):
    v = math.floor(a*x/b) - a * math.floor(x/b)
    max_v = max(v, max_v)

print(max_v)

Submission status: Time Limit Exceeded

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

max_value = -10000
for x in range(N+1):
#    print(x)
    value = math.floor(A*x/B)-A*math.floor(x/B)
    if value > max_value:
        max_value = value
#        print("max_value revised", max_value)
    else:
#        print("no change")
        pass
print(max_value)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def f1(a, b, x):
  return int(a * x / b)

def f2(a, b, x):
  return a * f1(1, b, x)

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

for x in range(n + 1):
  ans = f1(a, b, x)-f2(a, b, x)
  if ans > result:
    result = ans

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

l = []

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

print(max(l))

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    A, B, N = map(int, input().split(" "))
    max_score = -float("inf")
    log = []

    for x in range(1, min(B, N)+1):
        score = math.floor((A*x)/B) - A*math.floor(x/B)
        log.append(score)
        max_score = max(max_score, score)
    print(max_score)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = 0
for i in range(1, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp
print(ans)

Submission status: Time Limit Exceeded

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

if B / 2 > N:
    num = reversed(range(1, N + 1))
else:
    num = range(1, N + 1)

for x in num:
    value = int(A * x / B) - A * int(x / B)
    if answer <= value:
        answer = value
    
    if x == B:
        break

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,C = map(int,input().split())
D = []

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

print(max(D))

Submission status: Time Limit Exceeded

Solution code:
A,B,N = list(map(int,input().split()))
Ans = []
for i in range(1,B-1):
    if i <= N:
        a = ((A*i)/B)//1 - A * ((i/B)//1)
        Ans.append(a)
for i in range(1,10**12):
    x = B*i - 1
    if x <= N:
        a = ((A*x)/B)//1 - A * ((x/B)//1)
        Ans.append(a)
    else:
        break
print(int(max(Ans)))

Submission status: Time Limit Exceeded

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


ancer = []

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

Submission status: Time Limit Exceeded

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

import math
M = 0
for x in range(N+1):
    Z = math.floor(A * x / B) - A * math.floor(x / B)
    if M < Z:
        M = Z
print(M)

Submission status: Time Limit Exceeded

Solution code:
import math

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

list=0
for i in range(1,N+1):
  if i>B:
    list=math.floor(A*i/B)
  else:
    c=(math.floor((A*i)/B))-(A*(math.floor(i/B)))
    if list<c:
      list=c
print(list)

Submission status: Time Limit Exceeded

Solution code:
def LI(): return list(map(int,input().split()))
A,B,N = LI()
ans = 0
for i in range(max(N-N%B-B,1),N+1):
    temp = (A*i//B)-A*(i//B)
    ans = max(ans,temp)
print(ans)

Submission status: Time Limit Exceeded

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

from sys import stdin
import numpy as np


def main():
    a, b, n = map(int, stdin.readline().split())
    ans = -float('inf')
    for x in range(n, -1, - 1):
        _ = np.floor(a * x / b) - a * np.floor(x / b)
        if _ > ans:
            ans = _
            if _ == n:
                break

    print(int(ans))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
def floorfunction(A,B,x):
  sTgt=math.floor(A*x/B)-A*math.floor(x/B)
  return sTgt
  
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  sTgt_past=0
  for i in range(1,N+1):
    sTgt=floorfunction(A,B,i)
    if(i==0):
      sMax=sTgt
    else:
      sMax=max(sMax,sTgt)
    if((sTgt_past>0)and (sTgt==0)):
      break
    sTgt_past=sMax
  print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result)

Submission status: Time Limit Exceeded

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

max = 0
for i in range(1,N+1):
    m = int(A*i/B)-A*int(i/B)
    if m>max: max = m
print(max)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
ans=0
for x in range(min(B+1,N+1)):
    a=int(A*x/B)
    b=A * int(x/B)
    ans=max(ans,a-b)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
A,B,N=map(int,input().split())
if(N<=B):
    x = np.array([j for j in range(N+1)])
else:
    x = np.array([j for j in range(B+1)])    
val=np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(val)))

Submission status: Time Limit Exceeded

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

tmp_pre = 0
for i in range(1, N+1):
  if (i%B!=0):
    continue
  else:
    tmp = (A*(i-1))//B - A*((i-1)//B)
    if tmp > tmp_pre:
      tmp_pre = tmp
if (B > N):
  print((A*N)//B - A*(N//B))
else:
  print(int(tmp_pre))

Submission status: Time Limit Exceeded

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

print(max(c))

Submission status: Time Limit Exceeded

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

ans = []
for x in range(n+1):
  if x < b:
    ans.append((a*x)//b)

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,N = LMIIS()

    ans = 0
    for i in range(max(0,N-10**7),N+1):
        ans = max(floor(A*i/B)-A*floor(i/B),ans)
    for i in range(1,min(N+1,N-10**7)):
        ans = max(floor(A*i/B)-A*floor(i/B),ans)
    
    
    print(ans)


    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

import math



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

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)

Submission status: Time Limit Exceeded

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

x = n//2
lst = []
while x <= n:
    lst.append(int(a*x/b) - a*int(x/b))
    x += 1

print(max(lst))

Submission status: Time Limit Exceeded

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

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

  if ans > maxans:
    maxans = ans

print(maxans)

Submission status: Time Limit Exceeded

Solution code:
import math


a, b, n = map(int, input().split())
li = []
for x in range(1, n+1):
    an = math.floor(a*x/b) - a * math.floor(x/b)
    li.append(an)
print(max(li))

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
s = set()
for i in range(1,n+1):
    s.add(int((a*i)/b)-a*(int(i/b)))

print(max(s))

Submission status: Time Limit Exceeded

Solution code:
import math


nums = [int(e) for e in input().split()]

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

max_score = -1
score = -1

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

print(max_score)

Submission status: Time Limit Exceeded

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

if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n)
else:
    maxT = 0
    i = n
    while i >= n-10000000 and i>= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    print(maxT)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if N<B:
  L = N
else:
  L = B

for i in range(L):
  x = i+1
  Y = int(float(A*x)//float(B)) - A*(x//B)
  if Y>Ymax:
    Ymax = Y
print(Ymax)

Submission status: Time Limit Exceeded

Solution code:
import math
S =  list(map(int,input().split()))
A = S[0]
B = S[1]
N = S[2]
d = []
for i in range(1,N+1):
    t = math.floor(A*i/B)-math.floor(i/B)*A
    d.append(t)
print(max(d))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x=0
list =[]
while  0<= x <= n :
    k = int(a*x/b) - a* int(x/b)
    list.append(k)
    x += 1
print(max(list))

Submission status: Time Limit Exceeded

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

list=0
for i in range(1,N+1):
  if i>B:
    list=A*i//B
  else:
    c=((A*i)//B)-(A*(i//B))
    if list<c:
      list=c
print(list)

Submission status: Time Limit Exceeded

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

x = 0
while x <= n:
    ans1 = int(a*x/b) - a * int(x/b)
    x += 1
    ans2 = int(a*x/b) - a * int(x/b)
    if ans1 > ans2:
        break
print(ans1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N =list(map(int,input().split()))
def floor(a):
  if a.is_integer():
    return(int(a))
  else:
  	return(int(math.ceil(a)-1))
_che = 0
for x in range(N+1):
  y = floor((A*x)/B) - A*floor(x/B)
  if _che < y:
    _che = y
print(_che)

Submission status: Time Limit Exceeded

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

if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n)
else:
    maxT = 0
    i = n
    while i >= n-1000000000 and i>= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    print(maxT)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = 0
for x in range(1, n+1):
    front = (a*x - (a*x)%b)//b
    back = ((x - x%b))//b
    ans = max(ans, front - back * a)
print(ans)

Submission status: Time Limit Exceeded

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

an = 0

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

Submission status: Time Limit Exceeded

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

max = 0
for i in range(1,int(n)+1,1):
    r = (int(a)*i // int(b)) - (int(a)* (i//int(b)))
    if r > max:
        max = r

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = []
for x in range(n+1):
  if x < b:
    ans.append((a*x)//b - a * (x//b))

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    inputs = input().split(' ')
    a = int(inputs[0])
    b = int(inputs[1])
    n = int(inputs[2])

    ans = 0
    for x in range(1, n+1):
        if (a*x % b == 1) or (x < b):
            pre_ans = math.floor(a*x/b) - a * math.floor(x/b)
            if ans < pre_ans:
                ans = pre_ans
            else:
                pass

        else:
            pass

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

from sys import stdin
import numpy as np


def main():
    a, b, n = map(int, stdin.readline().split())
    ans = -float('inf')
    for x in range(0, n + 1):
        _ = np.floor(a * x / b) - a * np.floor(x / b)
        if _ > ans:
            ans = _
            if _ == n:
                break

    print(int(ans))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans=[]

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

ans.sort()

print(ans[-1])

Submission status: Time Limit Exceeded

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

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

print(max(L))

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
    num=int(A*i/B)-A*int(i/B)
    if max_num<=num:
        acc+=1
        i+=acc
        max_num=num
    else:
        i-=acc
        for j in range(i):
            num=int(A*j/B)-A*int(j/B)
            if max_num<=num:
                max_num=num
            else:
                break
        break
    
print(max_num)

Submission status: Time Limit Exceeded

Solution code:
import collections
from collections import defaultdict
import math
import numpy as np
import re
import itertools


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

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)

Submission status: Time Limit Exceeded

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


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

print(ans)

Submission status: Time Limit Exceeded

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

max = 0
if b - 1 > n:
    x = n
else:
    x = b - 1

while x <= n:
    tmp = (a * x // b) - a * (x // b)
    if max < tmp: max = tmp
    x += b

print(max)

Submission status: Time Limit Exceeded

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

max_s = []
for i in range(n+1):
    num = int((a*i)/b) - a*int(i/b)
    max_s.append(num)
print(max(max_s))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
pre_x = list()
ind = B-1
while ind <= N:
    pre_x.append(ind)
    ind += B

if len(pre_x) == 0:
    ans = int(A*N/B) - A*int(N/B)
    print(ans)
else:
    ans = 0
    for x in pre_x:
        ans = max(ans, int(A*x/B) - A*int(x/B))
    
    print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math

A, B, N = list(map(int, stdin.readline().rstrip().split()))

ans = []

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

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Ansermax = 0

for x in range(N+1):
    Anser = 0

    Anser = int((a*x)//b)-a*int(x//b)
    
    if Ansermax < Anser:
        Ansermax = Anser

print(Ansermax)

Submission status: Time Limit Exceeded

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

def asahi(i):
  return int(a*i/b)-a*int(i/b)
c=asahi(0)
for k in range(n+1):
  c=max(c,asahi(k))
print(c)

Submission status: Time Limit Exceeded

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


max=0
for x in range(n+1):
    value=(a*x//b)-a*(x//b)
    if value>max:
        max=value
print(max)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def main():
  from builtins import input, int, map
  import math
  readline = stdin.readline
  A, B, N = map(int, readline().split())
  max = 0
  
  for x in range(N+1):
    tmp = math.floor(A * x / B) - A * math.floor(x / B)
    if tmp > max:
      max = tmp
  
  print(max)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def floor(t):
    return math.floor(t)

def main():
    input1 = input().split()
    A = int(input1[0])
    B = int(input1[1])
    N = int(input1[2])

    output = 0
    result = 0
    for x in range(N+1):
        result = floor(A*x / B) - A*floor(x/B)
        if result > output:
            output = result

    print(output)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def check(A, B, mid):
    return (A * mid // B) - A * (mid // B)


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

    ans = 0
    max_int = min(N, B)
    for i in range(1, max_int + 1):
        tmp = check(A, B, i)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(_max)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
max=0
x=0
while int(x//b)==0 and x<=n:
    if max < (int((a*x)//b) - a*(int(x//b))):
        max=(int((a*x)//b) - a*(int(x//b)))  
    x+=1
print(max)

Submission status: Time Limit Exceeded

Solution code:
def f1(a, b, x):
  return int(a * x / b)

def f2(a, b, x):
  return a * f1(1, b, x)

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

for x in range(n + 1):
  if f1(a, b, x)-f2(a, b, x) > result:
    result = f1(a, b, x)-f2(a, b, x)

print(result)

Submission status: Time Limit Exceeded

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

x = 0
lst = []
while x <= n:
    lst.append(int(a*x/b) - a*int(x/b))
    x += 1

print(max(lst))

Submission status: Time Limit Exceeded

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

for i in range(min(N+1, B)):
    p = A * i // B
    q = i // B * A
    ans = max(ans, p - q)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = (int(i) for i in input().split())
l = []
for i in range(N):
    x = N
    c = int((A*x)/B)
    d = A * int(x/B)
    e = c - d
    l.append(e)
    N -= 1 
print(max(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if B > N:
    reverse = True
    num = reversed(range(1, N + 1))
else:
    reverse = False
    num = range(1, N + 1)

for x in num:
    value = int(A * x / B) - A * int(x / B)
    if answer <= value:
        answer = value
    
    if x == B:
        break

print(answer)

Submission status: Time Limit Exceeded

Solution code:
import math

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

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)


max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int, input().split())
answer=0
import math
Blist=[]
apple=min(B,N)
for i in range(1,apple+1):
    newans=math.modf(i/B)[0]*A
    newans//=1
    answer=newans if newans>answer else answer
print(int(answer))

Submission status: Time Limit Exceeded

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

max_v = 0
for i in range(1, N + 1):
    current_max_v = int(A * i // B) - A * int(i / B)
    max_v = max(max_v, current_max_v)
print(max_v)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

A, B, N = LI()

X = 0
b = 0

for n in range(N+1):
    a = int(A*n//B) - A*int(n//B)
    if a < b:
        print(b)
        break
    b = a
if a == b:
    print(b)

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split())
n = min(n, b)
mem = {}
for x in range(1, n + 1):
    if mem.get(((a * x) % b, x % b)) is not None:
        break    
    else:
        mem[((a * x) % b, x % b)] = math.floor(a * x / b) - a * math.floor(x / b)
print(max(mem.values()))

Submission status: Time Limit Exceeded

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

import math
M = 0
for x in range(max(N-5000000,0),N+1):
    Z = math.floor(A * x / B) - A * math.floor(x / B)
    if M < Z:
        M = Z
print(M)

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in reversed(range(b)):
    if i<=n:
        print(math.floor(a*i/b))
        break