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 as m

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

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

else:
  list = []
  flag = 0
 
  list += [m.floor(A * 0 / B) - A * m.floor(0 / B)]
  
  for x in range(1, N + 1):
    list += [m.floor(A * x / B) - A * m.floor(x / B)]
    if list[x] < list[x - 1]:
      print(list[x - 1])
      flag = 1
      break
      
  if flag == 0: print(max(list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
a,b,n = map(int,input().split())
ans = 0
for k in range(1,int(n/b)+1+1):
    if k*b -1 <= n :
        # print(k,k*b-1,n)
        ans = max(ans, np.floor(a*(k*b-1)/b) - a * (k-1))
    else:
        # print(k,k*b-1,n)
        ans = max(ans, np.floor(a*n/b) - a*(k-1))
        # break
print(int(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
else: m=[0]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Submission status: Time Limit Exceeded

Solution code:
import math

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

    ans = 0

    for x in range(1, B+1):
        if x == N + 1:
            print(ans)
            return
        tmp_ans = math.floor(A * x / B) - A * math.floor(x / B)
        if ans <= tmp_ans:
            ans = tmp_ans

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

if B > N:
    print(A*N//B)
else:
    L = []
    for x in range(B-1,N):
        L.append(A*x//B-A*(x//B))
    print(max(L))

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans1 = 0
ans2 = 0
ans = 0
ax = 0
x = 0
for _ in range(1, n+1):
    ax += a
    x += 1
    ans1 = ax//b
    if x % b == 0:
        ans2 += a
        x = 0
    ans = max(ans, ans1-ans2)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(10**3,N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Time Limit Exceeded

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

for x in range(N+1):
  a=math.floor((A*x)/B)
  b=math.floor(x/B)
  ans=a-A*b
  l.append(ans)
  
print(max(l))

Submission status: Time Limit Exceeded

Solution code:
from math import floor
from collections import deque

def main():
    A,B,N=map(int,input().split())
    d=deque()
    ok=False
    
    for x in range(N+1):
        tmp=floor(A*x/B)-A*floor(x/B)
        if tmp<floor(A*(x-1)/B)-A*floor((x-1)/B) and x>=1:
            ok=True
            print(d[-1])
            exit()
        
        d.append(tmp)
        
    print(d[-1])
    exit()
    
if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append
 
#for x in range(n+1):
#    append(int((a*(x))/b) - a * int(x/b))
#print(max(li))
def f(x):
    return int((a*(x))/b) - a * int(x/b) 
li = [f(x) for x in range(n+1)]
print(max(li))

Submission status: Time Limit Exceeded

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

res = []
f = 0
b = 0

for x in range(N+1):
    f = math.floor((A*x)/B)
    b = A * math.floor(x/B)
    """print(str(f)+"-"+str(b)+"="+str(f-b))"""
    res.append(f - b)

print(max(res))

Submission status: Time Limit Exceeded

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 7 and Npower < 10:
    for i in range(0,10**6+10**5):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**6-10**5-10**4-10**3-10**2,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))

Submission status: Time Limit Exceeded

Solution code:
import math

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

answer = 0

if(A < B):
  prev = -1
  
  for i in range(1, N+1):
    temp = math.floor((A * i) / B) - (A * math.floor(i / B))
    answer = max(answer, temp)
    
    if prev > temp:
      break
else:
  prev = -1
  
  for i in range(1, N+1):
    temp = math.floor((A * i) / B) - (A * math.floor(i / B))
    answer = max(answer, temp)
    
    if prev > temp:
      break

      
print(answer)

Submission status: Time Limit Exceeded

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


num = list(map(int, input().split()))
a = num[0]
b = num[1]
n = num[2]
x = 1
max_num = 0
while x % b != 0 and x <= n:
    new_num = f(a, b, x)
    if max_num < new_num:
        max_num = new_num
    x += 1
print(max_num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import deque
a,b,c=[int(_) for _ in input().split()]
k=c-1
s=math.floor((k*a)/b)-a*math.floor(k/b)
t=math.floor((c*a)/b)-a*math.floor(c/b)
lista=set()
lista.add(s)
lista.add(t)
listb=deque()
t=0
while t<=c:
    t+=b-1
    if t>=c:
        if t==c:
           listb.append(t) 
        break
    listb.append(t) 
    t+=1
    listb.append(t)
for p in listb:
    lista.add(math.floor((p*a)/b)-a*math.floor(p/b))
print(max(lista))

Submission status: Time Limit Exceeded

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

MAX=[]

while N>0:
    ans = math.floor(A*N/B)-A*math.floor(N/B)
    MAX.append(ans)
    N-=1

print(max(MAX))

Submission status: Time Limit Exceeded

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

print(y)

Submission status: Time Limit Exceeded

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

l = [N]
x = 1

while N > x*B -1:
  l.append(x*B-1)
  x += 1

m = [math.floor(A*i/B)-A*math.floor(i/B) for i in l]
print(max(m))

Submission status: Time Limit Exceeded

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

def binary_search():
    low = 1
    high = n

    m = 0

    while low < high:
        mid = (low + high) // 2

        l = int(a*low/b) - a * (int(low/b))
        h = int(a*high/b) - a * (int(high/b))

        if h > l:
            high = mid 
            m = max(m, h)
        else:
            low = mid 
            m = max(m, l)

    return m


print(binary_search())

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  for i in range(N,N-2*B,-1):
    if i<0:
      break
    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())
#(a*x)//b - a*(x//b) の最大値を求める
ax_list = [a*i for i in range(1,n+1)]
if b > n:
    # ax//b だけ考えればいい
    print(a*n//b)
else:
    # ax//b か　bより大きいx で探す
    x = 2*b-1
    print(a*(b-1)//b if a*(b-1)//b >= (a*x)//b-a*(x//b) else (a*x)//b-a*(x//b))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
 
a, b, n = list(map(int, input().split()))
 
ans = 0
for x in range(b//a, n+1):
    if x > b:
        break
    tmp = math.floor((a*x)/b) - a*math.floor(x/b)
    #print(x, math.floor((a*x)/b), a*math.floor(x/b))
    if tmp > ans:
        ans = tmp
 
print(ans)

Submission status: Time Limit Exceeded

Solution code:
li=list(map(int,input().split()))
a=li[0]
b=li[1]
n=li[2]
li=[]
ans=int(a*0/b)-a*int(0/b)
for x in range(n+1):
    s=int(a*x/b)-a*int(x/b)
    li.append(s)
li.sort()
li.reverse()
ans=li[0]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

arr = list(map(int, input().split()))

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

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

print(max_answer)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = [int(i) for i in input().split()]
x = N
M = A*N//B
ans = -float("inf")

for _ in range(min([10**7,N])):
    s = (A*x)//B - A*(x//B)
    ans = max([ans,s])
    x -= 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

list=[]
for i in range(int(N)):
    X = i+1
    Y = math.floor((int(A)*X)/int(B)) - int(A)*math.floor(X/int(B))
    list.append(Y)
print(max(list))

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(N-10**6):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
now=0
if n>=b:
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print(max(ans,0))

Submission status: Time Limit Exceeded

Solution code:
import math

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

    value = 0
    maxValue = 0

    while value <= n:
        res = math.floor((a * value) / b) - a * math.floor(value / b)
        maxValue = max(res, maxValue)
        value += 1
    
    print(maxValue)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    a,b,c=map(int,input().split())
    d=[]
    for i in range(c+1):
        e=(a*i)//b-a*(i//b)
        d.append(e)
    print(max(d))
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for x in range(N+1):
  floor = int(A*x/B) - A*int(x/B)
  if Max < floor:
    Max = floor
    
print(Max)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
c = 0
for i in range(1,n+1):
    if c == (math.floor(a*i/b)-a*math.floor(i/b)):
        continue
    elif c < (math.floor(a*i/b)-a*math.floor(i/b)):
        c = (math.floor(a*i/b)-a*math.floor(i/b))
    elif c > 0 and c > (math.floor(a*i/b)-a*math.floor(i/b)):
        print(c)
        exit()
print(c)

Submission status: Time Limit Exceeded

Solution code:
c=list(map(int,input().split()))
bunsi=c[0]
bunbo=c[1]
n=c[2]
k=n//bunbo
d=[n]
if k!=0:
    for i in range(0,k):
        d.append(bunbo*(i+1)-1)
def floor(x):
    return ((bunsi*x)//bunbo)-(bunsi*(x//bunbo))
temp= floor(d[0])
if len(d)>1:
    for i in range(1,len(d)):
        temp=max(temp,floor(d[i]))
    print(temp)
else:
    print(temp)

Submission status: Time Limit Exceeded

Solution code:
import math

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(n,1,-1):
    tmp = (a*i // b) - (a*(i//b))
    ans = max(ans, tmp)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math as mt

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

    maxn = 0
    
    if N > B:
        for x in range(B-1, N+1, B):
            temp = mt.floor(A*x/B) - A*mt.floor(x/B)
            if temp >= maxn:
                maxn = temp
            else:
                break
    elif N == B:
        maxn = mt.floor(A*(N-1)/B) - A*mt.floor((N-1)/B)
    else:
        maxn = mt.floor(A*N/B) - A*mt.floor(N/B)
    
    print(maxn)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(n+1):
    y = (a*i // b) - (a*(i//b))
    if ans <= y:
        ans = y
    else:
        continue
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 7 and Npower < 11:
    print(N-10**6-10**5-10**4-10**3-10**2)
    for i in range(0,10**6+10**5):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**6-10**5-10**4-10**3-10**2,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
def floor(x):
  return int(x//1)
list = []
if N >= B:
  for x in range(B+1):
    list.append(floor((A*x)/B)-(A*floor(x/B)))
else:
  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())
max = 0
wait = int(B/A) + 1
for x in range(1, N+1):
    fun = int(A*x/B) - A*int(x/B)
    if x == 1:
        x0 = fun
    elif x > wait:
        if x0 == fun:
            break
    if max < fun:
        max = fun
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np

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

print(max(l))

Submission status: Time Limit Exceeded

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

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)

l=list()
for m in range(int(n/2),n+1):
  l.append(asahi(m))
print(max(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

a, b, n = [int(x) for x in sys.stdin.readline().rstrip().split()]
mx = 0

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

print(mx)

Submission status: Time Limit Exceeded

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

for x in range(N + 1):
  result = math.floor((A * x)/B) - A * math.floor(x/B)
  if (maxResult < result):
    maxResult = result
print(maxResult)

Submission status: Time Limit Exceeded

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

x = 0
now = 0
result = 0
for i in range(n+1):
    x = i
    if x >b:
        continue
    now = (((a * x)//b)) - (a * (x//b))
    #now = math.ceil(((a * x)/b)) - (a * math.ceil(x/b))
    #print("now=",now,"x=",x)
    #print(result,now)
    result = max(result,now)

print(result)

Submission status: Time Limit Exceeded

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

max =0
for i in range(1,int(n)+1):
  tmp=math.floor(int(a)*i/int(b))-int(a)*math.floor(i/int(b))
#  print('i',i,"tmp",tmp,'max=',max)
  if tmp>=max:
    max=tmp
    i+=1
  elif tmp-max <= 0:
    break
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
x = 1
m = 0
def floor(t):
    return int(t)
while x <= N:
    r = floor(A * x / B) - A * floor(x / B)
    if r > m:
        m = r
    x += 1
print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

if b >= n:
    if n%b != 0:
        x = n 
        ans = math.floor(a*x/b) - a*math.floor(x/b)
        print(ans)
        exit(0)
    else:
        x = n-1 
        ans = math.floor(a*x/b) - a*math.floor(x/b)
        print(ans)
        exit(0)

f = [-1 for _ in range(b)]
for x in range(1, b+1):
    f[x-1] = math.floor(a*x/b) - a*math.floor(x/b)
print(max(f))

Submission status: Time Limit Exceeded

Solution code:
import math

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

max_value = 0

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

    
print(max_value)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  for i in range(B):
    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())
lst=[]
for i in range(int(n/2),n+1):
  lst.append(int(a*i/b)-a*int(i/b))    
print(max(lst))

Submission status: Time Limit Exceeded

Solution code:
def main(n,m,q):
    l=[]
    for i in range(1,q+1):
        j=(n*i)//m-n*(i//m)
        l.append(j)
    print(max(l))

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
import math


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

    print(ans)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    if n > 10 ** 11:
        for x in range(n, 10 ** 9, -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 10:
        for x in range(n, 10**8 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 8:
        for x in range(n, 10**6 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass


    elif n > 10 ** 6:
        for x in range(n, 10**4 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    elif n > 10 ** 4:
        for x in range(n, 10**2 , -1):
            fx = math.floor(a/b * x) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
N = list(map(int, input().split()))
ans = []
for i in range(N[2] + 1):
    f_1 = (N[0]*i)//N[1]
    f_2 = N[0] * (i//N[1])
    ans.append(f_1 - f_2)
ans.sort()
print(ans[-1])

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int,input().split())
 
L = []
 
if N >= 10000000:
  for i in range(10000000):
    r = (N-i+1)/B
    L.append(int(A*r)-A*int(r))
else:
  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=map(int,input().split())
ans=0
for i in range(1,n+1):
    t=int((a*i)/b)-a*int(i/b)
    ans=max(ans,t)
print(ans)

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
x=0
if N>B:
  N=B
while x<=N:
  if A*x > B:
    y = floor((A*x)/B) - A*floor(x/B)
    if _che < y:
      _che = y
  x+=1
print(_che)

Submission status: Time Limit Exceeded

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

import math
x = 0
t1 = 0
t2 = 0

f_tmp=0
f_max=0

while x < n+1:
    t1 = math.floor(a*x/b)
    t2 = a*math.floor(x/b)
    f_tmp = t1- t2
    if(f_max < f_tmp):
        f_max = f_tmp
    x += 1

print(f_max)

Submission status: Time Limit Exceeded

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

temp_prev = 0
temp_curr = 0
if b <= 100:
    x = 0.0
else:
    x = min(n, b - 100.0)

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

    if temp_curr < temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 0
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts += 1
		if maxs < tmp:
			maxs = tmp
		if conts == 20000000:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
input_line = list(map(int, input().split()))

A = input_line[0]
B = input_line[1]
N = input_line[2]
N += 1
result = 0

for i in range(N):
    cal = int((A * i) / B) - A * int(i / B)
    if cal >= result:
        result = cal

print(result)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = -float('inf')

for x in range(1, N +1):
    a = (A*x) // B - A * (x // B)
    ans = max(ans, a)

print(ans)

Submission status: Time Limit Exceeded

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

answer=0

for i in range(1,N+1):
    f=int(A*i/B)-A*int(i/B)
    if f>answer:
        answer=f
    if f<answer:
        break
    #print(f)
print(answer)