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
a,b,n=map(int, input().split())
c = np.array([])
for x in range(n+1) :
     c = np.append(c,int(a*x/b)-a* int(x/b))
    
print(int(np.max(c)))

Submission status: Time Limit Exceeded

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,N = FLI()
max = 0
for i in range(1,N+1):
    j = floor((A*i)/B) - A * floor(i/B)
    if j > max:
       max = j

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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-30**6-10**6,N+1)[::-1]:
    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(' '))

_max = 0
for x in range(N, int(N/2), -1):
    if x < 1:
        break
    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:
a, b, n = map(int, input().split())


def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)


ans = function(0)
for i in range(n):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

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
    if ans > c:
        break

print(ans)

Submission status: Time Limit Exceeded

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

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])
f = math.floor(b/2)
M=[]
if e < d:
    print(math.floor(c*e/d))
else:
    for i in range(math.floor(b/2)+1):
        M.append(math.floor(c*(f+i)/d) - c*math.floor((f+i)/d))
    print(max(M))

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int, input().split())
x = 0
m = int(n**0.5)
for i in range(n,m,-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
def inputOneLine():
	global S
	S=input()
	return S.split(' ')

def printn(sss):
	return(str(sss) + ' ')

##main#######################################
S=''
lines=inputOneLine()
A=int(lines[0])
B=int(lines[1])
N=int(lines[2])
max=0
for i in range(1,N+1):
	if i==B:continue
	ans11=(A * i)/B
	ans1= math.floor(ans11)
	ans22=i/B
	ans2= math.floor(i/B)
	ans3 = ans1 - A*ans2

	#print(str(i) +':'+ printn(ans3))
	#print(str(i) +':'+ printn(ans11) + \
	#printn(ans1)  + \
	#printn(ans22*5)  + \
	#printn(ans2)  + \
	#printn(ans3))

	if max<ans3 :
		max=ans3
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N=map(int,input().split())
D=int(A*B/math.gcd(A,B))
maxi=0
if D<N:
  for i in range(1,D+1):
    if (i%B)*A/B-(A*i)%B/B>maxi:
      maxi=(i%B)*A/B-(A*i)%B/B
      if maxi==A*(B-1)/B:
        break
else:
  for i in range(1,N+1):
    if (i%B)*A/B-(A*i)%B/B>maxi:
      maxi=(i%B)*A/B-(A*i)%B/B
      if maxi==A*(B-1)/B:
        break
print(int(maxi))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

max_v = 0
for i in range(1, N + 1):
    current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
    max_v = max(max_v, current_max_v)
    # 循環したらとめる
    if i > 100000000000:
        break
print(max_v)

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):
        Bi = i/B
        calc = int(A*Bi) - A*int(Bi)
        floor_list.append(calc)

    print(max(floor_list))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

for k in range(0, (N+1)//B + 1):
    
    x = (k+1)*B - 1
    if x > N:
        x = N
    func = floor(A*x/B) - A * floor(x/B)
    f = max(func, f)
    
print(f)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
a, b, n = list(map(int, input().split()))

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

# print((a * n) // b - a * (n // b))

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = [int(i) for i in input().split()]
ret = math.floor(A*N/B) - A * math.floor(N/B)
i = 1
while N - i > 1 :
  if ret < math.floor(A*(N-i)/B) - A * math.floor((N-i)/B) :
    ret = math.floor(A*(N-i)/B) - A * math.floor((N-i)/B)
  i += 1

print(ret)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
max_int = 0
if a != b:
    if n < b:
        max_int = int((a*n)/b) -a * int(n/b)
    else:
        #for i in range(n, n-max(int(b/a), int(a/b), int(a%b), int(b%a))-1, -1):
        for i in range(1, n):
            tmp = int((a*i)/b) -a * int(i/b)

            #print(i)
            #print(tmp)
            if max_int < tmp:
                max_int = tmp

print(max_int)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

Submission status: Time Limit Exceeded

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

for i in range(1, n + 1):
    z = ((a * i) // b) - a * (i // b)
    count.append(z)

print(max(count))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

for x in range(1,B+1):
    if x > N:
        break
    ans = (x % B) / B * A
    if ans > z:
        z = ans
print(int(z))

Submission status: Time Limit Exceeded

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

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

if B <= N:
    n = [i + 1 for i in range(math.ceil(N/B))]
    check_num += [B*i - 1 for i in n]

else:
    check_num += [N]

for i in check_num:
    temp = math.floor(A*i/B) - A * math.floor(i/B)
    if ans < temp:
        ans = temp

print (ans)

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 = x*B-1
  x += 1
 
print(math.floor(A*l/B)-A*math.floor(l/B))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = list(map(int, input().split()))
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)
m = 0
temp = 0
for i in range(1,N):
    temp = f(i)
    if f(i) > f(i+1) :
        m = f(i)
        break
    else:
        m = f(i+1)
print(m)

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=(a*i//b)-a*(i//b)
  if tmp>=max:
    max=tmp
    i+=1

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,c = map(int,input().split())
res = [] 
i=0
while(i<=c):
    ress = math.floor((a*i)/b) - a * math.floor(i/b)
    res.append(ress)
    i=i+1
print(max(res))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if b == 1:
    r = [0]
else:
    i = 0
    r = []
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
print(max(r))

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
j = 0
i = 0
if N < B:
  print(int(A*N/B))
else:
  while int(i/B) < 1:
    if int(i/B) == 0:
      k = int(A*i/B) - A*int(i/B)
      if k > j:
        j = k
    i += 1
  print(j)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B:
    n = int(N/B)
    for i in range(n):
        x = i*B
        temp = ans1 = int((A*(x-1))/B)-A*int((x-1)/B)
        if temp > ans:
            ans = temp
    n = n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
    ans5 = int((A*(n))/B)-A*int((n)/B)
else:
    ans1 = ans
    ans2 = ans
    ans3 = ans
    ans4 = ans
    ans5 = ans


print(max(ans, ans1, ans2, ans3, ans4, ans5))

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
li=list(input().split())
a=int(li[0])
b=int(li[1])
n=int(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 = 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



while flag and index <= min(N,B):
    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:
a, b, n = map(int, input().split())
x = 0
m = 0
for x in range(b-10000000000,b):
  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())

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
import math
s = input()
a, b, n = map(int, s.split(' '))

# if b == 0:
#     print(0)
#     exit()

# irr_deno = Fraction(a,b).denominator

# if irr_deno < b:
#     step = irr_deno
# else:
#     step = b

max = 0

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

print(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 = []

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
    loop = min(B+1, N+1)
    for x in range(loop)[::-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
import numpy as np
a,b,n = map(int, input().split())
floor_list = []
num_max = 0
for x in range(n+1):
  if math.floor(a*x/b) - a*math.floor(x/b) >= num_max:
    num_max = math.floor(a*x/b) - a*math.floor(x/b)


print(num_max)

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
cnt=0

while wk_n >= 1 and cnt <= 10000000:
#    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
    cnt+=1

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

Submission status: Time Limit Exceeded

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

max1 = (a*2)//b - a*(2//b)
max2 = (a*(n//2))//b - a*((n//2)//b)


for i in range(2,n//2):
    if (a*i)//b - a*(i//b) >= max1:
        max1 = (a*i)//b - a*(i//b)

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

if max1 > max2:
    print(max1)
else:
    print(max2)

Submission status: Time Limit Exceeded

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

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:
# 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))
    for i in range(1,ans+1):
        x= i*B-1
        start = max((math.floor(A*x/B)-A*(i-1)),start)
    print(start)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split(" "))
maxe=0
for x in range(n,-1,-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:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, n = LI()
ans = -INF
if b - 1 > n:
    x = n
    ans = max(ans, a * x // b - a * (x // b))
else:
    x = b - 1
    while True:
        ans = max(ans, a * x // b - a * (x // b))
        x += b
        if x > n:
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import floor, ceil
a, b, n = map(int, input().split())
ans = 10 ** 6 * (-1)
x = 1
while x <= n:
    tmp = floor(a * x / b) - a * floor(x / b)
    ans = max(ans, tmp)
    x += ceil(b / a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

ABN=np.array(input().split(" "),dtype=np.int64)
A=ABN[0]
B=ABN[1]
N=ABN[2]

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

print(out)

Submission status: Time Limit Exceeded

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

ans = -1
if(a % b == 0):
    x = b-1
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc
elif(n < 10 ** 8):
    for x in range(1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(n-(10**7),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(output)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ab = a/b
maxi = 0
st = max(0, n-a-1)
for x in range(st, n+1):
    z = 0
    if x < b:
        z = math.floor(ab * x)
    else:
        z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

for x in range(0, st):
    z = 0
    if x < b:
        z = math.floor(ab * x)
    else:
        z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

print(maxi)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

for x in range(1,B+1):
    ans = (x % B) / B * A
    if ans > z:
        z = ans
    if x > N-1:
        break
print(int(z))

Submission status: Time Limit Exceeded

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

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

if B <= N:
    n = [i + 1 for i in range(math.ceil(N/B))]
    check_num += [B*i - 1 for i in n]

else:
    check_num += [i + 1 for i in range(N)]

for i in check_num:
    temp = math.floor(A*i/B) - A * math.floor(i/B)
    if ans < temp:
        ans = temp

print (ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int, input().split())
max = 0
j = int(n/2)
for i in range(j, 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())
print(max([int(a*x/b)-a* int(x/b) for x in range(n+1)]))

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)
        if (A*x<B):
            tmp1=0
        if (x<B):
            tmp2=0
        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:
A, B, N = [int(x) for x in input().strip().split(" ")]

fs = []
for x in range(N, max(N - B, 0), -1):
    fs.append( (A * x // B) % A)
print(max(fs))

Submission status: Time Limit Exceeded

Solution code:
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

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

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

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]:
    maxlist.append(func(A,B,i))
  
print(max(maxlist))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def main():
    A, B, N = map(int, input().split())
    ans = 0
    for i in range(1, min(N + 1, 10**8 + 1)):
        ans = max(ans, (A*i)//B - A * (i//B))
        # print(ans, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from pprint import pprint as pp
from pprint import pformat as pf

import math


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

    m = 0
    for x in range(n + 1):
        k = ((a * x) // b) - a * (x // b)
        #print('x, k, m', x, k, m) # debug
        m = max(m, k)
    print(m) # debug

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:
import math
a,b,c = map(int,input().split())
res = [] 
for i in range(c+1):
    ress = math.floor((a*i)/b) - a * math.floor(i/b)
    res.append(ress)
print(max(res))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def siki(A, B, X):
	return math.floor((A*X)/B) - A*math.floor(X/B)

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

if B > A * N:
	print(0)
else:
	if N < B:
		k = N
	else:
		k = B
	for i in range(1, k+1):
		if max_value < siki(A,B,i):
			max_value = siki(A,B,i)

	print(max_value)

Submission status: Time Limit Exceeded

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

def main():
    A, B, N = map(int, input().split())
    ans = -1
    for x in range(min(B, N), max(min(B, N)-N, -1), -1):
        ans = max(ans, f(x, A, B))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

d = 0
ans = 0

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:
A,B,N = map(int,input().split())
 
n = [int(x) for x in range(1,N+1)]
 
answer_list=[]
for x in n:
    Y = x//B
    answer = int(A*x/B) - A * Y
    answer_list.append(answer)
print(max(answer_list))

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

ans = -1
if(a % b == 0):
    x = b-1
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc
elif(n < 10 ** 8):
    for x in range(1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(n-(10**8),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Time Limit Exceeded

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

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

print(max(li))

Submission status: Time Limit Exceeded

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

def floor(t):
  return int(t)

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

Submission status: Time Limit Exceeded

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    ans = int(a*n/b) - a*int(n/b)
    for i in range(1,n//b+1):
        if i*b<=n:
            x = int(a*(b*i-1)/b) - a*int((b*i-1)/b)
            ans = max(ans,x)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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