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: Wrong Answer

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

k =0

for i in range (0, 1000000):
	p = math.floor(A*i/B)-A*math.floor(i/B)
	if p> k:
		k = p

print(k)

Submission status: Wrong Answer

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 = 0
    for i in range(min(10**6+10,n+1)):
        ans = max(ans,int(a*i/b)-a*int(i/b))
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# map(int,input().split())
# int(input())
import math
a,b,c = map(int,input().split())
maxcnt = 0
for i in range(min(c+1,114514)):
	cnt = math.floor(a*i/b)-a*math.floor(i/b)
	if maxcnt < cnt:
		maxcnt = cnt
print(cnt)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
print( A * N // B - A * (N // B))

Submission status: Wrong Answer

Solution code:
a,b,c=map(float,input().split())
x=max(b-1,c)
import math
print(math.floor(a*x/c)-a*math.floor(x/c))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,n = map(int,input().split())
if b-1 >= n:
  x = b-1
else:
  x = n
print((a*x//b)-(a*(x//b)))

Submission status: Wrong Answer

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

print(A*N//B - A*(N//B))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
print(math.floor((A*(B-1))/B) - A*math.floor((B-1)//B))

Submission status: Wrong Answer

Solution code:
from math import floor

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

print(floor(a*x / b) - a * floor(x/b))

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
x = N
floor = lambda A,B,x: (A*x)//B - A*(x//B)
prev = floor(A,B,x)
while True:
    x -= 1
    c = floor(A,B,x)
    if prev <= c:
        prev = c
    else:
        break
print(prev)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
if B >= N - 1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    # n = getN()
    # s = input().strip()
    # nums = getList()
    a,b,x = getList()
    if x < b:
        print(math.floor((a*x)/ b) - a * math.floor(x/b))
    else:
        k = b * (x // b) - 1
        print(math.floor((a * k) / b) - a * math.floor(k / b))
        # print(math.floor((a * (b - 1)) / b))
        # print(math.floor(b-1 / b))
    # print((10*99) / 2 - 10 * (98/2))
    # print(10/2 - 0)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Max = 0
for x in range(1, n + 1):
    Max = max(Max, (a * x) // b - a * (x // b))
print(Max)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
import math
maximum = 0
for x in range(N+1): # xは非負なので0含む？
  val = (A * x // B) - A * (x // B)
  if maximum > val:
    break
  maximum = max(val, maximum)
print(maximum)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
maximum = 0
for x in range(N+1): # xは非負なので0含む？
  val = (A * x // B) - A * (x // B)
#  print(val)
  if maximum > val:
    break
  maximum = max(val, maximum)
print(maximum)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
import math
maximum = 0
for x in range(N+1): # xは非負なので0含む？
  val = math.floor(A * x / B) - A * math.floor(x / B)
#  print(val)
  if maximum > val:
    break
  maximum = max(val, maximum)
print(maximum)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
import math
maximum = 0
for x in range(N+1): # xは非負なので0含む？
  val = math.floor(A * x / B) - A * math.floor(x / B)
  maximum = max(val, maximum)
print(maximum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    a, b, n = map(int, input().split())
    ans = -10 ** 10

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

    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(1,N+1):
  score = 0
  score = math.floor(A*i/B) -A* math.floor(i/B)
  ans = max(ans,score)
print(ans)

Submission status: Time Limit Exceeded

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

resolve()

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
M = 0
for x in range(1, N + 1):

    M = max(M, (A * x) // B - A * (x // B))

print(M)

Submission status: Time Limit Exceeded

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

max = 0

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

print(max)

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
import math

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

print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math


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


def main(A, B, N):
    last = 0
    x = 0
    while x <= N:
        tmp = f(A, B, x)
        if tmp < last:
            print(last)
            return
        else:
            last = tmp
            x += 1
    else:
        print(last)
        return


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

Submission status: Time Limit Exceeded

Solution code:
import math


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


def main(A, B, N):
    last = 0
    x = 0
    while x <= N:
        tmp = f(A, B, x)
        if tmp < last:
            print(last)
            return
        else:
            last = tmp
            x += 1
    else:
        print(last)


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

Submission status: Time Limit Exceeded

Solution code:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  A,B,N=map(int,pin().split())
  t=int(B/A)
  ans=0
  for x in range(t,N+1):
    ans=max(ans,int(A*x/B)-A*int(x/B))
  print(ans)
  return 
main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
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:
import math
import decimal

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

ans=[]

for i in range(1,n+1):
  x=decimal.Decimal(a*i/b)
  y=decimal.Decimal(i/b)
  c=math.floor(x)-a*math.floor(y)
  ans.append(c)

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(B+1):
    if i > N:
        break
    n = (A * i // B) - A * (i // B)
    ans = max(ans, n)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

y=0

for i in range(1,10**12):
    if math.floor(A*i/B)-math.floor(i/B)>y:
        y==math.floor(A*i/B)-math.floor(i/B)
    else :
        print(y)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

A,B,N = map(int,input().split())
ans = 0
if B <= N:
    N = B
for x in range(B//A , N+1):
    n = f(A,B,x)
    if n > ans:
        ans = n

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

A,B,N = map(int,input().split())
ans = 0
for x in range(B//A , N+1):
    n = f(A,B,x)
    if n > ans:
        ans = n

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(max)

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
max_L=0
x=0
while x<B and x<=N:
	L=int(A*x/B)-A*int(x/B)
	if max_L<=L:
		max_L=L
		x+=1
	else:
		break

"""
if B>N:
	while x<=N:
		L=int(A*x/B)-A*int(x/B)
		if x<N:
			if max_L<=L:
				max_L=L
				x+=1
			else:
				break
		else:
			if max_L<=L:
				max_L=L
				break
			else:
				x-=1
				break
else:
	while x<B:
		L=int(A*x/B)-A*int(x/B)
		if max_L<=L:
			max_L=L
			x+=1
		else:
			break
"""
print(max_L)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import floor
def main():
    a, b, n = map(int, input().split())

    amariset = set()
    for i1 in range(1, n + 1):
        amari = (i1 / b) % 1
        if amari in amariset:
            break
        else:
            amariset.add(amari)
    r = 0
    for amarie in amariset:
        rt = floor(amarie * a) - floor((amarie * a) % 1)
        r = max(r, rt)
    print(r)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import floor
def main():
    a, b, n = map(int, input().split())
    r = 0
    for i1 in range(1, n + 1):
        t = floor(a * i1 / b) - a * floor(i1 / b)
        r = max(r, t)
    print(r)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
x = 0
mi = 100000
for i in range(n+1):
    t = ((a%b)*(i%b))%b - a*(i%b)
    if t<mi :
        mi = t
        x = i

ans = (a*x)//b - a*(x//b)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
x = 0
mi = 100000
for i in range(n+1):
    t = ((a%b)*(i%b))%b - a*(i%b)
    if t<mi :
        mi = t
        x = i
        ans = (a*i)//b - a*(i//b)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


sum = 0

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

max_v = 0
if n < b:
  max_v = floor(a * n / b)
else:
  for i in range(b - 1, n + 1, b):
    t = floor(a * i / b) - a * floor(i / b)
    if t > max_v:
      max_v = t
print(max_v)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

max_v = 0
for i in range(n + 1):
  t = floor(a * i / b) - a * floor(i / b)
  if t > max_v:
    max_v = t
print(max_v)

Submission status: Time Limit Exceeded

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

if i==0:
    print(han)

Submission status: Time Limit Exceeded

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

if i==0:
    print(han)

Submission status: Time Limit Exceeded

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

if i==0:
    print(han)

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

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

maxc = -10**5
for i in range(n+1):
    c = int(a*i/b) - a*int(i/b)
    maxc = max([maxc, c])

print(maxc)

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
a,b,n = list(map(int, input().split()))

x = np.array([x for x in range(1,n+1)])
A = (a*x)//b
B = a * (x//b)
ANS = A-B
print(max(ANS))

Submission status: Time Limit Exceeded

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

T = 0
for i in range(1,n+1)[::-1]:
  t = (a*i)//b - a*(i//b)
  if T < t:
    T = t

print(T)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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


for i in range(N,-1,-1):
    if (N+1)//B-1 == i//B:
        ans_i = i
        break

if N//B == 0:
    ans_i = N

print((A*ans_i)//B - A*(ans_i//B))

Submission status: Time Limit Exceeded

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

floor_floor = []
for x in range(N+1):
    floor_floor.append((A*x)//B - A*(x//B))

print(max(floor_floor))

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
n = 0
for x in range(10**12):
    c = int(a*x/b)
    d = int(x/b)
    if c - a*d >= n:
        n = c-d
print(n)

Submission status: Time Limit Exceeded

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

def main():

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

    if n < b:
        print((a*n)//b)
        exit()

    num = n//b
    ans = 0

    for i in range(1,num+1):
        num2 = i*b-1
        #print(num2)
        temp = (a*num2)//b - a * (num2//b)
        ans = max(temp,ans)

    print(max(ans,(a*n)//b - a * (n//b)))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


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


if n < b:
    print((a*n)//b)
    exit()

num = n//b
ans = 0

for i in range(1,num+1):
    num2 = i*b-1
    #print(num2)
    temp = (a*num2)//b - a * (num2//b)
    ans = max(temp,ans)

print(max(ans,(a*n)//b - a * (n//b)))

Submission status: Time Limit Exceeded

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


if n < b:
    print((a*n)//b)
    exit()

num = n//b
ans = 0

for i in range(1,num+1):
    num2 = i*b-1
    #print(num2)
    temp = (a*num2)//b - a * (num2//b)
    ans = max(temp,ans)

print(max(ans,(a*n)//b - a * (n//b)))

Submission status: Time Limit Exceeded

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

if n < b:
    print((a*n)//b)
    exit()

num = n//b
ans = 0

for i in range(1,num+1):
    num2 = i*b-1
    #print(num2)
    temp = (a*num2)//b - a * (num2//b)
    ans = max(temp,ans)



print(max(ans,(a*n)//b - a * (n//b)))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int,input().split())
n = 0
x = 1
while (n+1)*B-1 < N:
    n += 1

if n == 0:
    x = N
else:
    x = n*B-1

print(int(A*x/B) - A*int(x/B))

Submission status: Time Limit Exceeded

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

yuka = lambda a,b: (a-(a%b))//b

for x in range(b):
  if x>n:
    break
  score = yuka(a*(x%b),b)
  ans = max(ans,score)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int, input().split())
ans = 0
N = [x for x in range(1,n+1) if (a*x)%b < a*(x%b)]

yuka = lambda a,b: (a-(a%b))/b

for x in N:
  score = yuka(a*x,b) - a*yuka(x,b)
  ans = max(ans,score)

print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int, input().split())
ans = 0
N = [x for x in range(1,n+1) if a*(x/b - int(x/b))>1]

for x in N:
  k = x/b
  f = math.floor(a*k) - math.floor(k)*a
  if ans<f:
    ans = f

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

x = 1
k = 1/b
f = math.floor(a*k) - math.floor(k)*a
ans = 0
while x<=n:
  if ans<f:
    ans = f
  x += 1
  k = x/b
  f = math.floor(a*k) - math.floor(k)*a
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
c=-9999999
for i in range(1,min(b+1,n+1)):
  k=((a*i)//b)-(a*(i//b))
  if int(k)>c:
    c=int(k)
print(c)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
c=-9999999
for i in range(1,n+1):
  k=(int(a*i)/b)-(a*(int(i/b)))
  if int(k)>c:
    c=int(k)
print(c)

Submission status: Time Limit Exceeded

Solution code:
def main():  
  a, b, n = map(int, input().split())
  q = n//b
  k = b-1
  ans = -1
  for i in range(q):
    current=((a*k)//b - a*(k//b))
    if ans < current:
      ans = current
    k = k+b
  current = ((a*n)//b - a*(n//b))
  if ans < current:
      ans = current
  print(ans)
  
if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


y = [(a*i)//b-a*(i//b) for i in range(1, n+1)]
ans = max(y)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
from decimal import Decimal
ans =0
for i in range(1, n+1):
    y = (a*i)//b-a*(i//b)
    ans = max(ans, y)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
A,B,N=[int(i) for i in input().split()]

maxf=0
LCM=np.lcm(A,B)
for x in range(1,min(LCM,N)+1):
    f=math.floor(A*x/B)-A*math.floor(x/B)
    if maxf<f:
        maxf=f
print(maxf)

Submission status: Time Limit Exceeded

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

maxf=0
for x in range(1,min(B,N)+1):
    f=math.floor(A*x/B)-A*math.floor(x/B)
    if maxf<f:
        maxf=f
print(maxf)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

func = []
diff = 0
max = 0

for x in range(1, n+1):
    func.append(floor(a*x/b) - a*floor(x/b))
    if max < func[-1]:
        max = func[-1]
    if x > 2:
        diff = func[-1] - func[-2]
    if diff < 0:
        break

print(max)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

func = []
max = 0

for x in range(1, n+1):
    if floor(a*x/b) < a*floor(x/b):
        break
    func.append(floor(a*x/b) - a*floor(x/b))
    if max < func[-1]:
        max = func[-1]
    if x > 2:
        diff = func[-1] - func[-2]
#    if diff < 0:
#        break

#    if max < floor(a*x/b) - a*floor(x/b):
#        max = floor(a*x/b) - a*floor(x/b)
print(max)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

func = []
max = 0

for x in range(1, n+1):
    func.append(floor(a*x/b) - a*floor(x/b))
    if max < func[-1]:
        max = func[-1]
    if func[-1] < 0:
        break
#    if max < floor(a*x/b) - a*floor(x/b):
#        max = floor(a*x/b) - a*floor(x/b)
print(max)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# ABC 165 D - Floor Function

a,b,n = map(int, input().split())
l =[(int((a/b)*(i+1)) - a*int((i+1)/b)) - (int((a/b)*(i)) - a*int((i)/b)) for i in range(1, n+1)]

left = 0
right = n-1
mid = (left+right)//2

while right - left > 1:
    if l[mid] <= 0:
        right = mid
        mid = (left+right)//2
    else:
        left = mid
        mid = (left+right)//2

res = right +1
print((int((a/b)*(res)) - a*int((res)/b)))

Submission status: Time Limit Exceeded

Solution code:
a,b,n= map(int,input().split())
t=[]
for k in range (n+1):
  s= int(a*k/b)-a*int(k/b)
  t.append(s)
  if k>=b:
    break
print(max(t))

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

def main():
    a, b, n = list(map(int, input().split()))
    
    floor_list = []
    
    for i in range(n+1):
        floor_1 = int(Decimal(a*i/b))
        floor_2 = a * int(Decimal(i/b))
        floor_list.append(floor_1 - floor_2)
    
    #print(floor_list)
    #floor_list.sort()
    #print(floor_list[-1])
    print(max(floor_list))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

def main():
    a, b, n = list(map(int, input().split()))
    
    floor_list = []
    
    for i in range(n+1):
        floor_1 = int(Decimal(a*i/b))
        floor_2 = a * int(Decimal(i/b))
        floor_list.append(floor_1 - floor_2)
    
    print(max(floor_list))

if __name__ == '__main__':
    main()