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 numpy as np#not for pypy

def main():
    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")
    #second_input = input().split(" ")

    A = first_input[0]
    B = first_input[1]
    N = first_input[2]

    floor_list = []
    for i in range(0,N+1):
        calc = A*i//B - A*(i//B)
        floor_list.append(calc)

    print(max(floor_list))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
kind=set()
bef=-100
count=0
for i in range(1,n+1):
    num=calc(i)
    if num in kind:
        if 0==num:
            if bef!=0:
                if count==0:
                    count+=1
                else:
                    break
    kind.add(num)
    bef=num
print(max(kind))

Submission status: Time Limit Exceeded

Solution code:
import math 
A,B,n=map(int,input().split())
step = math.ceil(B/A)
ans=0
for i in range(1,n+1,step):
  tmp=math.floor(A*i/B)-(A*math.floor(i/B))
  if tmp>ans:
    ans=tmp
print(ans)

Submission status: Time Limit Exceeded

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

def unko(num):
    c = (a*num)//b
    d = (num//b)*num
    e = c - d
    return e

t =  [unko(i) for i in range(1,n+1)]
print(max(t))

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from functools import reduce
# from collections import deque
# from math import factorial
# import collections
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
same = 0
# print(ans)
for i in range(n, int(pow(n, 0.75))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
        if count == 1:
            print(ans)
            exit()
    elif a*i//b - a*(i//b) == 0:
        count += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
 
def g(t):
    return int(A*t/B)-A*int(t/B)
 
Max_x=0
 
for i in range(N):
    if g(i)<g(i+1):
        Max_x=i+1
        
    elif g(i)>g(i+1):
        break
        
    
print(g(Max_x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

if B <= N:
    max = math.floor(A * (B - 1) / B) - (A * math.floor((B - 1) / B))
else:
    for i in range(1, N + 1):
        temp = math.floor(A*i/B) - (A * math.floor(i/B))
        # print(str(i) + ' ' + str(temp))
        if bk_temp > temp:
            max = bk_temp
            break
        if max < temp:
            max = temp
        bk_temp = temp

print(max)

Submission status: Time Limit Exceeded

Solution code:
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())
ans = 0
ans_max = 0
for x in range(1,N+1):
    ans = int(float(A*x)/float(B))-A*int(float(x)/float(B))
    if ans_max < ans:
        ans_max = ans
    if x > A and x > B:
        break
print(ans_max)

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

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

# max_ans = 0
# for x in range(N+1)[::-1]:
#     print(x)
#     ans = math.floor(A * x / B) - A * math.floor(x / B)
#     if ans < max_ans:
#         print(max_ans)
#         sys.exit()
#     else:
#         max_ans = ans
# print(max_ans)

if B <= N:
    x = B - 1
    while x <= N:
        x += B
        ans.append(math.floor(A * x / B) - A * math.floor(x / B))
    print(max(ans))

else:
    max_ans = 0
    for x in range(N+1)[::-1]:
        #print(x)
        ans = math.floor(A * x / B) - A * math.floor(x / B)
        if ans < max_ans:
            print(max_ans)
            sys.exit()
        else:
            max_ans = ans
    print(max_ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

def main():
    A,B,N=map(int,input().split())
    d=deque()
    
    for x in range(N+1):
        #tmp=((A*x)//B)-A*(x//B)
        tmp1=((A*x)//B)
        tmp2=A*(x//B)
        tmp=tmp1-tmp2
        
        if x>=1:
            if d[-1]>tmp:
                break
        
        d.append(tmp)
        
    print(d[-1])
    exit()
    
if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

maxNum = 0
x = 1
while x <= N:
  num = math.floor((A * x) // B) - A * math.floor(x // B)
  x += 1
  if num >= maxNum:
    maxNum = num
  if maxNum == N:
    break

print(maxNum)

Submission status: Time Limit Exceeded

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

n = b if n > b else n
ans = 0
for x in range(n, 0, -1):
    if x > b:
        continue
    ans = max(a * x // b - a * (x // b), ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = map(int, input().split())
count = 0
ans = 0
l = 0
if n > 1000:
  l = 500

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

    Anser = 0

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

print(Ansermax)

Submission status: Time Limit Exceeded

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

max_of_x = min(B-1, N)
max = int(A*max_of_x/B)

n=0
while(1):
    n+=1
    x=B*n-1
    if x>N:
        break
    score = int(A*x/B) - A*int(x/B)
    if score>max:
        max = score
print(max)

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
TEST_LIST=[]

for i in range(N):
    TEST_LIST.append(int((A * i) / B) - A * int(i / B))
print(max(set(TEST_LIST)))

Submission status: Time Limit Exceeded

Solution code:
import math

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

c = 0
ans = 0
for i in range(1,10**18) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    ans = max(ans,math.floor((a*x)/b)-a*math.floor(x/b))
    if c == 1 :
        break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
start =  b // a
count = 0
check = start % b
count = 0
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)
    if i % b == check and count != 0:
        break
    count += 1
print(math.ceil(ans))

Submission status: Time Limit Exceeded

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

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

ans.sort(reverse=True)
print(ans[0])

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
  nums = [i for i in range(N//2, N+1)]
  for i in nums:
    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:
import copy
s = input().split()
A = int(s[0])
B = int(s[1])
N = int(s[2])
s = 0

if B > N:
	for i in range(N+1):
		y = int(A * i / B) - A * int(i / B)
		if s < y:
			s = copy.copy(y)
else:
	for i in range(B+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())
# S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]

if N < B:
    a = int(A * N / B)
    b = A * int(N / B)
    print(a - b)
    exit(0)

ans = 0
before_ans = 0
for i in range(1, N + 1):
    a = int(A * i / B)
    b = A * int(i / B)
    ans = max(ans, a - b)
    if before_ans > a - b:
        break
    # if ans == min(A - 1, B - 1):
    #    break
    before_ans = a - b
print(ans)

Submission status: Time Limit Exceeded

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

def floor(m):
    return int(m)

d=0
for x in range(n+1):
    c= floor(a*x/b) - a*floor(x/b)
    if d<=c:
        d=c

print(d)

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    if not x % B: continue
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
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))
def kansuu(n,b):
  if n>b:
    n=b
  _che = 0
  x=0
  while x<=n:
    y = floor((A*x)/B) - A*floor(x/B)
    if _che < y:
      _che = y
    x+=1
  return(_che)

print(kansuu(N,B))

Submission status: Time Limit Exceeded

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

s=0
if B<=N+1:
  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:
A,B,N=map(int,input().split())
t=(A*(B-1))//B
if N<B:
  a=A*N//B
else:
  for x in range(B,N+1):
    if x%B==0:
      l=[(A*(x-1))//B-A*((x-1)//B)]
  if t>=max(l):
    a=t
  else:
    a=max(l)
print(a)

Submission status: Time Limit Exceeded

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

    return max

if __name__ == '__main__':
    print(main())

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]

def unko(num):
    c = (a*num)//b
    d = (num//b)*num
    e = c - d
    return e

t =  [unko(i) for i in range(1,n+1)]
print(max(t))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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



for i in range(1,n+1):

  tmp=int((a*i//b)-a*(i//b))
  if tmp>=max:
    max=tmp
    i+=1
  elif tmp-max <= 0:
    break
print(max)

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 = (int(n/b) + 1) * b - 1
max_num = 0
while x % b != 0:
    if x > n:
        pass
    else:
        new_num = f(a, b, x)
        if max_num < new_num:
            max_num = new_num
            break
print(max_num)

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 = 0
for i in range(int(a[2]/2), a[2]+1):
    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())
# まずはx/Bがなるべく割り切れない方が良い．
# つまり最大のあまりを出す．
if N>=B-1:
    max_amari=B-1
else:
    max_amari = N
# 1~Nのxに対してmax_amariを満たすxの候補を上げる
x_l=[]
max_num=max_amari
while max_num<=N:
    x_l.append(max_num)
    max_num += B
# 候補の中で最もmod_B(Ax)がすくないものが一番である
min_amari=10**13
minx=0
for x in x_l:
    amari=((A%B)*(x%B))%B
    if amari<min_amari:
        minx=x
import math
print(math.floor(A*minx/B)-A*math.floor(x/B))

Submission status: Time Limit Exceeded

Solution code:
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)
a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    ret = f(a, b-1, b)
    for kk in range(1, k+1):
        ret = max(ret, f(a,b*kk-1,b))
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = input().split()
number = 0
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
    if num > number:
      number = num
print(number)

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 - 10.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:
import math
a, b, n = (int(x) for x in input().split())
max = 0
for i in range(n):
  if max < math.floor(a*(i+1)/b)-a*math.floor((i+1)/b):
    max = math.floor(a*(i+1)/b)-a*math.floor((i+1)/b)
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()


arg = list(map(int, input().split())) # 1行, 配列
A = arg[0]
B = arg[1]
N = arg[2]
maxim = 0

for x in range(N, -1, -1):
  t = math.floor(A * x / B) - A * math.floor(x / B)
  if t > maxim:
    maxim = t

print(maxim)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = 0

for v in range(1, n+1):
    if ans < (int((a * v)/ b) - (a * int(v/b))):
        ans = (int((a * v)/ b) - (a * int(v/b)))
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import math

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

tans = 0

if B <= N:
  for i in range(B-1,N+1):
    ans = math.floor(A*i/B) - A*math.floor(i/B)
    #print(i,math.floor(A*i/B), math.floor(i/B))
    tans = max(ans,tans)
else:
  tans = math.floor(A*N/B)
  
#for i in range(1,N+1):
#  ans = math.floor(A*i/B) - A*math.floor(i/B)
#  print(i,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(" "))
maxv = 0
for i in range(1, N+1):
    v = int(A*i / B)  - A * int(i / B)
    if v > maxv:
        maxv = v
print(maxv)

Submission status: Time Limit Exceeded

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

wk_n = n
wk_xxx = 0
wk_x = 0

while wk_n >= 1:
#    print(a,b,n,wk_n,wk_x,wk_n/b - math.floor(wk_n/b))
    if wk_n/b - math.floor(wk_n/b)  >= wk_xxx :
        wk_xxx = wk_n/b - math.floor(wk_n/b)
        wk_x = wk_n
    wk_n-=1

print(math.floor(a*wk_x/b)-a*math.floor(wk_x/b))

Submission status: Time Limit Exceeded

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

A, B, N = MAP()

left, right = 0, N

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


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

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

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

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

ans = 0
if B > N:
    ans = f(N)
else:
    i = 1
    while i*B <= N:
        ans = max(ans, f(i*B-1))

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

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


def g(x):
    global A
    global B
    global N
    return ((A*(x%B)) - ((A*x)%B)) / B


m = -1e12
mi = False
t = (N+1) // B
for i in range(t):
    gg = g(t*B - 1)
    if gg > m or mi == False:
        m = gg
        mi = True


if (N+1)%B != 0:
    gg = g(N)
    if gg > m or mi == False:
        m = gg
        mi = True

print(int(m))

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = (int(i) for i in input().split())  
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())

if n<b:
  qlist = range(n+1)
else:
  qlist = range(b)
  
anslist = list(map(lambda x:a*x//b,qlist))

print(max(anslist))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def func(a,b,x):
    val = (a*x)//b - a*(x//b)
    return val

a, b, n = map(int, input().split())
if n < b:
    print(func(a,b,n))
else:
    ans = []
    for i in range(n,0,-1):
        ans.append(func(a,b,i))
    print(max(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) :
    score, _ = math.modf(x/B)
    if score > max_score:
        max_score = score
    else:
        break

print(int(A*max_score))

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    a, b, n = map(int, input().split())
    print(max(list(map(lambda x:(a*x)//b - a*(x//b), range(1, n+1)))))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
A, B, N = map(int, input().split())
max_val = -1000000000000000000
max_x = 0
for x in range(N+1):
    y = np.floor(A/B*x) - A*np.floor(x/B)
    if max_val < y:
        max_val = y
        max_x = x
print(int(max_val))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
mx = 0
count = 0
for a in range(N, -1, -1):
    count += 1
    new = int(A*a/B) - A*int(a/B)
    mx = max(mx, new)

print(mx)

Submission status: Time Limit Exceeded

Solution code:
import math

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

_max = 0
for x in range(N, int(N/2), -1):
    
    num =math.floor(A * x / B) - A * math.floor(x/B) 
    # print(num)
    if  num > _max:
        _max = num

print(_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
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))

num_max = np.amax(floor_list)
print(num_max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))

A,B,N =line[0],line[1],line[2]

ans = (N+1)//B
if ans ==0:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    start = (math.floor(A*N/B)-A*math.floor(N/B))
    #kouho =[0 for j in range(ans)]
    for i in range(1,ans+1):
        x= i*B-1
        start = max((math.floor(A*x/B)-A*math.floor(x/B)),start)
    print(start)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
x=-float('inf')
for i in range(n):
    x = max(x, int(a * n / b) - a * int(n / b))
    n-=1
print(x)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def num(x):
    return (a*x)//b - a*(x//b)

ma = num(1)

for i in range(2, n+1):
    if num(i) > ma:
        ma = num(i)
print(ma)

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)):
    if math.floor(i / b) != 0:
        continue
    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:
import math
import sys
input = sys.stdin.readline

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = list(map(int,input().split()))
if N <= 10000:
    C = [A*i//B-(A*(i//B)) for i in range(1,N+1)]
    print(max(C))
    exit()
C = [A*i//B-(A*(i//B)) for i in range(10000000)]
D = [A*i//B-(A*(i//B)) for i in range(N,N-10000000,-1)]
E = [A*i//B-(A*(i//B)) for i in range(N//2-10000000,N//2+10000000)]
print(max(max(C),max(D),max(E)))

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

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

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
    if ax % b == 0:
        ax = 0
        ans1 += 1
    else:
        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:
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)

mid = N//2
if (math.floor((A*mid)/B) - A*math.floor(mid/B)) < (math.floor((A*(mid+1))/B) - A*math.floor((mid+1)/B)):
    for i in range(mid, N+1):
        d = math.floor((A * i) / B) - A * math.floor(i / B)
        if ans <= d:
            ans = d
        else:
            print(ans)
            exit()
else:
    for i in range(0, mid+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():
    max = 0
    a, b, n = map(int, input().split())
    if n < b:
        max = int(a*n/b)
    else:
        for i in range(1, n+1):
            ans = int(a*i/b) - a*int(i/b)
            if max < ans:
                max = ans

    return max

if __name__ == '__main__':
    print(main())

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):
    ans=max(ans,int(A*x/B)-(A*int(x/B)))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
from numba import jit


@jit
def solve(A, B, N):
    ans = 0
    for x in range(N + 1):
        calc = math.floor(A * x / B) - A * math.floor(x / B)
        if ans <= calc:
            ans = calc
        else:
            return ans
    return ans


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

    print(solve(A, B, N))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
lst = []
i = 1
while True :
    if i > N :
        break
    else :
        c = int(A*i/B) - A * int(i/B)
        lst.append(c)
        i+= 1
print(max(lst))