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())

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N >= B:
        for x in range(B-1, N+1, B):
            k = x / B
            ans = int(A*k) - int(k)
            if ans > mini:
                mini = ans
    else:
        ans = int(A*(N)/B)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split(" "))
max = 0
for i in range(0, min(b + 1, n + 1)):
    temp = math.floor(a * i / b) - a * math.floor(i / b)
    max = temp if max < temp else max
    if max < temp and max != 0:
        break
print(max)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

n = [int(x) for x in range(1,N+1)]

answer_list=[]
for x in n:
    answer = int(A*x/B) - A * int(x/B)
    answer_list.append(answer)
print(max(answer_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

for x in range(int(n), int(n/8), -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    # print(n)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
# a, b = list(map(int, input().split()))
# sy, sx = map(int, input().split())
# gy, gx = map(int, input().split())

ans = a*n//b - a*(n//b)
count = 0
for i in range(n, int(pow(n, 0.5))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
    elif a*i//b - a*(i//b) == 0:
        count += 1
    if count > 1:
        print(ans)
        exit()

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from copy import deepcopy

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

score = 0
if a * n / b < 1:
    print(0)
    exit()

for i in range(n+1):
    tmp = int(a * i / b) - a * int(i / b)
    if score <= tmp:
        score = deepcopy(tmp)
    else:
        print(score)
        exit()
print(score)

Submission status: Time Limit Exceeded

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions

t = stdin.readline().rstrip().split()
a = int(t[0])
b = int(t[1])
n = int(t[2])

res = 0
for el in range(b + 1):
    tes = int(a * el / b) - a * int(el / b)
    if res < tes and el <= n:
        res = tes
print(res)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
ans = int((a * n) / b) - a * int(n / b)
tmp = n
for i in range(0, min(1000000, n)):
  n = n - 1
  ans=max(ans, int((a * i) / b) - a * int(i / b))
for i in range(min(1000000, n), min(10000000, n)):
  n = n - 1
  ans=max(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())
count=0
x=0
for i in range(N+1):
    result=(i/B)-(int(i/B))
    if count<result:
        count=result
        x=i
result=int(A*x/B)-(A*int(x/B))
print(result)

Submission status: Time Limit Exceeded

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

Ansermax = 0

if b < N :
    N = b

for x in range(N+1):
    if x//b >= 1:
        continue

    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:
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:
    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-9*10**6,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

number = input().split(" ")
A = int(number[0])
B = int(number[1])
N = int(number[2])
ans = []

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = tuple(map(int, input().split()))
j=0
ans=0

i=1
while i<n+1:
    c=i/b
    j=math.floor(a*c)-a*math.floor(c)
    ans=max(ans,j)
#    print(i,j)
    if ans!=j:
        i = i+b-1
    else:
        i= i+1

print(ans)

Submission status: Time Limit Exceeded

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

import heapq
import math

list=[]
heapq.heapify(list)
for x in range(n+1):
    value = -math.floor(a*x/b)+a*math.floor(x/b)
    heapq.heappush(list,value)


print(heapq.heappop(list)*(-1))

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))
    if _max > 0 and val == 0: break
    _max = max(_max, val)

print(_max)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

result = 0
base_num = 0

if n < b:
    result = math.floor((a*n)/b) - a * math.floor(n/b)
    print(result)
    sys.exit()
    
for x in range(1, n+1):
    if x % b == 0:
        base_num += 1
        continue
    if x % (b-1) == 0:
        result_child = math.floor((a*x)/b) - a * base_num
        if result_child > result:
            result = result_child
        continue

print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = [int(i)for i in input().split()]
tmpmax=0
for i in range(N+1):
  tmp=math.floor(A*i/B)-A*math.floor(i/B)
  if tmp > tmpmax:
    tmpmax=tmp
    #print("{},{}".format(i,tmp))
print(tmpmax)

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):
  if x < b:
    r = math.floor(a * x / b) - a * math.floor(x / b)
    if m < r:
      m = r
  else:
    break
    
print(m)

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<10**8):
  for i in range(N+1)[::-1]:
    maxlist.append(func(A,B,i))
else:#N>10**8
  for i in range(N-10**7,N+1)[::-1]:
    if(func(A,B,i)==A-1):
      maxlist.append(func(A,B,i))
      break
    else:
      maxlist.append(func(A,B,i))
  
print(max(maxlist))

Submission status: Time Limit Exceeded

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

print(max(floor_list))

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:
    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**7,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())

x = 0
now = 0
result = 0

    

for i in range(n+1):
    if x > b:
        break
    x = i
    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:
A, B, N = map(int, input().split())

def floor(t):
  return int(t)

x = 0
Ans_0 = 0
for i in range(N+1):
  Ans = floor(A * x / B) - A * floor(x / B)
  if Ans_0 < Ans:
    Ans_0 = Ans
  x = x + 1
  
print(Ans_0)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = input().split()
list = []
for i in range(1,int(n)+1):
    p = int(a)*i/int(b)
    p = int(p)
    
    z = i/int(b)
    z = int(z)
    q = int(a) * z
    num = p - q
    list.append(num)
m = max(list,key=int)
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
	elif val<max_:
		break
print(max_)

Submission status: Time Limit Exceeded

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  for x in range(1,N+1):
    p = (A*x)//B - A*(x//B)
    if p<s:
      break
    if p>s:
      s=p
print(s)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
ans=[]
for x in range(n+1):
    y=math.floor(a*x/b)-a*(math.floor(x/b))
    ans.append(y)
ans.sort(reverse=True)
print(ans[0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import math

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

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

if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

a = [int(i) for i in input().split()]

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

result = None
for i in range(1, a[2]+1):
    if not result:
        result = calc(a[0], a[1], i)
    else:
        result = max(result, calc(a[0], a[1], i))

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(max(list(map(lambda y: keisan(a, b, y) ,range(1,n+1)))))

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-1000000 and i>= 0:
        n = i%b
        m = (a*i)%b
        t = (a*n-m)//b
        if t > maxT:
            maxT = t
        i-=1
    wild = max(n//b, (n-1)//b)
    print(max(maxT, wild))

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

for i in range(1,min(b+1,n+1)):
    d = math.floor((a*i)/b)
    e = a*math.floor(i/b)
    if e>0:
        break
    ans = max(ans,d-e)
print(ans)

Submission status: Time Limit Exceeded

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

x = 0
max_score= -float('inf')
for x in range(N+1) :
    a, b = math.modf(x/B)
    score = int(A*a)
    if score > max_score:
        max_score = score

print(max_score)

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 = (a*x) // b#math.floor(a*x/b)
    t2 = a*(x//b) #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 = input().split()
A = int(A)
B = int(B)
N = int(N)
ans = 0
for x in range(N+1):
    if A*x < B:
        ans_2 = 0
    elif x < B:
        ans_2 = (A * x)//B
    else:
        ans_2 = (A * x)//B - (A * (x//B))
    if ans < ans_2:
        ans = ans_2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

tans = 0

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

print(tans)

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
    first = a*(b-1)//b
    second = (a*x)//b - a*(x//b)
    print(first if first >= second else second)

Submission status: Time Limit Exceeded

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

l = []
for x in range(1,n+1):
  ans = math.floor(a * x / b) - a * math.floor(x / b)
  l.append(ans)
print(max(l))

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

for i in range(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:
a, b, n = map(int, input().split())

if b < n:
    n = b

ans_lst = []
for x in range(1, n+1):
    y = x / b
    ans = int(a*y) - a*int(y)
    ans_lst.append(ans)
print(max(ans_lst))

Submission status: Time Limit Exceeded

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

c = int(a[0])
d = int(a[1])
e = int(a[2])

b = min([d,e])

M=[]
if e < d:
    print(math.floor(c*e/d))
else:
    for i in range(b):
        M.append(math.floor(c*i/d) - c*math.floor(i/d))
    print(max(M))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(max([int((A*(a+1))/B) - A*int((a+1)/B) for a in range(N)]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


ans = sorted(ans, reverse=True)
print(ans[0])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n = (int(x) for x in input().split())
max=0
if n>=b:
    max=int(a*(b-1)/b)
    for x in range(b,n+1):
        y=int(a*x/b)-a*int(x/b)
        if y>max:
            max=y
else:
    for x in range(n+1):
        y=int(a*x/b)-a*int(x/b)
        if y>max:
            max=y

print(max)

Submission status: Time Limit Exceeded

Solution code:
p = input().split()
k =[int(s) for s in p]
a = k[0]
b = k[1]
n = k[2]
t = []
def unko(num):
    c = (a*num)//b
    d = (num//b)*num
    e = c - d
    t.append(e)
for i in range(1,n+1):
    unko(i)
print(max(t))

Submission status: Time Limit Exceeded

Solution code:
a, b , n= input().split() 
a = int(a)
b = int(b)
n = int(n)
if b > n :
    print(a*n//b)
else:
    max = 0
    for i in range(1,n,1):
        r = (a*i // b) - a* (i//b)
        if r > max:
            max = r

    print(max)

Submission status: Time Limit Exceeded

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

for i in range(int(n/4),n+1):
    k = int(a*i/b)-a*int(i/b)
    lis.append(k)
    
print(max(lis))

Submission status: Time Limit Exceeded

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


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


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    a, b, n = wi()
    c = []
    for i in range(1, n+1):
        c.append(int(a*i/b) - a*int(i/b))
        if i >= b:
            break
    print(max(c))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N+1):
	y = int(A * i / B) - A * int(i / B)
	if s < y:
		s = copy.copy(y)

print(s)

Submission status: Time Limit Exceeded

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

print(max(y))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
max_num=n
if b-1<n:
    max_y=b-1
else:
    max_y=n
    
# if a<max_y:
#     max_m=a
# else:
#     max_m=max_y

import math

ans=0
for i in range(0,max_y+1):
    f=math.floor(i*a/b)-a*math.floor(i/b)
    ans=max(ans,f)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import random

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

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

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

print(max)

Submission status: Time Limit Exceeded

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

for x in range(n+1):
    y=math.floor(a*x/b)-a*(math.floor(x/b))
    ans.append(y)
ans.sort(reverse=True)
print(ans[0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
temp = [i for i in range(N+1)]

box = []

for num in temp:
    X = math.floor(A*num/B) - A * math.floor(num/B)
    box.append(X)

print(max(box))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

        m=l

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math

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

c = a/b
p = []

for x in range(n + 1):
    d = math.floor(c * x) - a * math.floor(x / b)
    p.append(d)
    p.sort()
    if len(p) == 2:
        del p[0]


print(p[0])

Submission status: Time Limit Exceeded

Solution code:
a, b , n= input().split() 
a = int(a)
b = int(b)
n = int(n)
if b > n :
    print(a*n//b)
else:
    max = 0
    for i in range(1,b,1):
        r = (a*i // b) - a* (i//b)
        if r > max:
            max = r

    print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import random

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

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

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import math

def has_duplicates(seq):
    return len(seq) != len(set(seq))

A,B,N = map(int, input().split())
List=[]
ListTwo=[]
i=1
j=0
while i<=N:
    one=math.floor((A*i)/B)
    two=math.floor(i/B)
    three=A*two
    ans=one-three
    List.append(ans)
    #print(ans)
    if has_duplicates(List)==True:
        ListTwo.append(ans)
        #print("2回目")
        #print(ListTwo)
        
        j+=1
        if j==max(List) and ListTwo==List[:max(List)]:
            #print("YES")
            break
        #break

    i+=1
#print("ans")
print(max(List))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(max(f(x) for x in range(1, N + 1)))

Submission status: Time Limit Exceeded

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

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

ans = 0

#bがnよりも大きい時
if b > n:
    ans = int(a*n/b)
    print(ans)
    exit()

#b==nのときは、終了間際の2個だけ比較する
elif b == n:
    for i in range(n-1,n+1):
        tmpans = int(a*i/b) - (a*int(i/b))
        if tmpans >= ans:
            ans = tmpans
    print(ans)
    exit()

#これ以外の時は、nはb値ごとにスキップする。
else:
    for i in range(1,n+1,b):
        tmpans = int(a*(i-2)/b) - (a*int((i-2)/b))
        if tmpans >= ans:
            ans = tmpans

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

index = 1
prev = -1
max_num = 0
flag = True
if B == 1:
    flag = False
    max_num = 0

if A >= B:
    flag = True
    max_num = calc(N)

while flag and index <= N:
    tmp = calc(index)
    if tmp < prev:
        flag = False
    else:
        prev = tmp
    if max_num < tmp:
        max_num = tmp
    index += 1

print(max_num)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
a,b,n=map(int,input().split())
mx=0
for x in range(n,int(n*.75)-1,-1):
    if x<b:
        c=(a*x)//b
    elif x==b:
        c=((a*x)//b)-a
    else:
        c=floor((a*x)/b)-(a*floor(x/b))
    if c>mx:
        mx=c
print(mx)

Submission status: Time Limit Exceeded

Solution code:
import math

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

def floor_t(A,B,y):
    return math.floor(A*y/B) - A*math.floor(y/B)

total = 0

# if A==B:
#     if A-1<=N:
#         print(floor_t(A,B,A-1))
#         exit(0)
#     else:
#         print(floor_t(A,B,N))
#         exit(0)

for x in range(N+1):
    if x%B==0:
        continue
    else:
        total = max(total,floor_t(A,B,x))

print(total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l = input().split()
a = int(l[0])
b = int(l[1])
n = int(l[2])
max = 0
calc = 0
for i in range(1, n+1):
  calc = float(a*i // b) - a * float(i//b)
  if max < calc:
    max = calc
print(int(max))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = input().split()
A = int(A)
B = int(B)
N = int(N)
ans = 0
for x in range(N+1):
    if A*x < B:
        ans_2 = 0
    elif x < B:
        ans_2 = int((A * x)/B)
    else:
        ans_2 = int((A * x)/B) - (A * int(x/B))
    if ans < ans_2:
        ans = ans_2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
A = [1]
Ap = 1/b-int(1/b)
B = 0
Bp = 0
c = 0
t = 0

for i in range(2, n+1):
    B = i/b - int(i/b)

    if B > Ap:
        Ap = B
        A[0]=i
        del A[1:1+c]
        c = 0
    elif B==Ap:
        A.append(i)
        c = c + 1
    else:
        continue

import math

ans = 0
for i in A:
    k = math.floor(a*i/b) - a*math.floor(i/b)
    if k>ans:
        ans = k

print(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))
    
    if i-1 >= 2:
    
        
            
        if ancer[i-2] > ancer[i-1]:
            break


print(max(ancer))

Submission status: Time Limit Exceeded

Solution code:
from copy import deepcopy

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

score = 0
for i in range(n+1):
    tmp = int(a * i / b) - a * int(i / b)
    if score <= tmp:
        score = deepcopy(tmp)
    else:
        print(score)
        exit()
print(score)