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:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    A, B, N = map(int, input().split())
    N = min(B-1, N)
    ret = 0
    for x in range(N+1):
        ret = max(ret, (x * A)//B - A * (x//B))

    print(ret)



if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

def Floor(x):
  c = x / int(b)
  d = int(a) * c
  ans = math.floor(d) - int(a) * math.floor(c)
  return ans

for x in range(1,int(n)+1):
  ans = Floor(x)
  if ans >= j:
    j = ans
print(j)

Submission status: Time Limit Exceeded

Solution code:
import math

bl=input().split()
A=int(bl[0])
B=int(bl[1])
C=int(bl[2])
m=0
for x in range(C+1):
  y=math.floor(A*x/B)-A*math.floor(x/B)
  if y>m:
    m=y
print(m)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans = 0
for x in range(min(B,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

A,B,N = map(int, 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())
max = 0
x = 0
n = int(B/A)
if(n < 1):n=1
if(A == 1 or B == 1):
  print(max)
else:
  while(x <= N):
    f = (A*x)//B - A*(x//B)
    #x += n
    x += 1
    #print(f)
    if(max <= f):
      max = f
    if(max != 0 and f == 0):
      break
  print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

a, b , n = map(int, input().split())
ans = []
i = 1
while i <= n:
    ans.append(math.floor(a*i / b) - a*math.floor(i/b))
    if (2 <= i) and (ans[i -1] < ans[i-2]):
        break
    i += 1
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

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


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

Submission status: Time Limit Exceeded

Solution code:
import math
n=input().split()
A=int(n[0])
B=int(n[1])
N=int(n[2])
ret=0
for i in range(N+1):
    temp = math.floor(A*i/B)-A*math.floor(i/B)
    if temp>ret:
        ret=temp
print(ret)

Submission status: Time Limit Exceeded

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

import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    if N < B:
        max_value = np.floor(A*N/B)
    else:
        init = int(np.ceil(B/A)) + 1
        for x in range(init, B+1):
            value = np.floor(A*x/B) - A * np.floor(x/B)
            #print(x, value)
            if value > max_value:
                max_value = value
    print(int(max_value))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    if N < B:
        max_value = np.floor(A*N/B)
    else:
        for x in range(B+1):
            value = np.floor(A*x/B) - A * np.floor(x/B)
            #print(x, value)
            if value > max_value:
                max_value = value
    print(int(max_value))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    if N < B:
        max_value = np.floor(A*N/B)
    else:
        for x in range(N+1):
            value = np.floor(A*x/B) - A * np.floor(x/B)
            #print(x, value)
            if value > max_value:
                max_value = value
    print(int(max_value))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    max_int = B
    if N < B:
        max_int = N
    for x in range(max_int+1):
        value = np.floor(A*x/B) - A * np.floor(x/B)
        #print(x, value)
        if value > max_value:
            max_value = value
    print(int(max_value))
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

ans_list = []

for i in range(int(b / 10), n + 1):
  #print(int((a * i) / b), a * int(i / b), int((a * i) / b) - a * int(i / b))
  ans = int((a * i) / b) - a * int(i / b)
  ans_list.append(ans)
print(max(ans_list))

Submission status: Time Limit Exceeded

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

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

ans_list = []

for i in range(int(b / 1000000), n + 1):
  #print(int((a * i) / b), a * int(i / b), int((a * i) / b) - a * int(i / b))
  ans = int((a * i) / b) - a * int(i / b)
  ans_list.append(ans)
print(max(ans_list))

Submission status: Time Limit Exceeded

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

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

ans_list = []

for i in range(n + 1):
  #print(int((a * i) / b), a * int(i / b), int((a * i) / b) - a * int(i / b))
  ans = int((a * i) / b) - a * int(i / b)
  ans_list.append(ans)
print(max(ans_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

result = -1000000000
for i in range(0,N+1):
    
    if floor(i) > result:
        result = floor(i)
        
print(result)

Submission status: Time Limit Exceeded

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

ans = []
for i in range(1, n+1):
    ans.append(a*i//b - a*(i//b))

print(max(ans))

Submission status: Time Limit Exceeded

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

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

for i in range(0,N+1):
    Get.append(floor(i))
print(max(Get))

Submission status: Time Limit Exceeded

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

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


print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

li = []
for x in range(n+1):
    li.append(int(a * x / b) - a * int(x / b))

print(max(li))

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)

if B<=N:
    x=[i for i in range(0,B+1,1)]
    
    y=[g(i) for i in x]
    
else:
    x=[i for i in range(0,N+1,1)]
    
    y=[g(i) for i in x]

print(max(y))

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)

x=[i for i in range(0,N+1,1)]

y=[g(i) for i in x]

print(max(y))

Submission status: Time Limit Exceeded

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

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

L.append(floor(N))
for i in range(N):
  while B * (i + 1) - 1 < N:
    L.append(floor(B * (i + 1) - 1))

print(max(L))

Submission status: Time Limit Exceeded

Solution code:
a,b,n = input().split()
a = int(a)
b= int(b)
mx=0
for x in range(int(n)+1):
  mmx = a*(x%b)-(a*x)%b
  if mx < mmx:
    mx = mmx
print(int(mx/b))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

a,b,n = LI()
import math

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:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

a,b,n = LI()
import math

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

Submission status: Time Limit Exceeded

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

def floor(x):
  return math.floor(A * x / B) - A * math.floor(x / B)
  
for i in range(N + 1):
  L.append(floor(i))
  
print(max(L))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
sys.setrecursionlimit(10**9)

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

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

    def bin(a):
        left = 0
        right = min(B-1,N)

        while right-left > 1:
            x = (right+left) // 2
            # print(left,right)
            if f(x) < a:
                left = x
            else:
                right = x

        # print("____")
        # print(right)
        return right


    for _a in range(A+1):
        a = A - _a
        x = bin(a)
        # print(x,a)
        if 0<=x<=N and f(x) == a:
            print(a)
            exit()


if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

import math
D = []
for x in range(1, N+1):
    D.append((A * (x % B) - A * (x % B) % B)/B)

print(int(max(D)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    mi = math.floor(B / N)
    for n in range(mi, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    mi = math.floor(A / N)
    for n in range(mi, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    for n in range(1, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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())
print(max(list( int(a*x/b//1 - x/b//1*a) for x in range(1,n+1) )))

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

max_value = 0
n = min(N, B-1)

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

    
print(max_value)

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(B):
  A_x = A * x
  left_ = int(A_x / B)
  right_ = A * int(x / B)
  fnc_ = left_ - right_
  if x <= N:
    ans = max(ans, fnc_)
    # print("入れ替わりans", ans)

  # print("     x", x)
  # print(" left_", left_)
  # print("right_", right_)
  # print("  fnc_", left_ - right_)


print(ans)

Submission status: Time Limit Exceeded

Solution code:
def floor(x) :
    return int(x)
    
s = input().split(" ")
a = int(s[0])
b = int(s[1])
n = int(s[2])
M = 0

for i in range(1,n+1) :
    if M<(floor(a*i/b)-a*floor(i/b)) :
        M = (floor(a*i/b)-a*floor(i/b))

print(M)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
if N > B:
	N = B
ans = 0
for x in range(1, 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 sys
input=sys.stdin.readline
A,B,N=map(int,input().split())
s=[0]
for x in range(N+1):
  if ((A*x)//B)-A*(x//B)>=max(s):
    s.append(((A*x)//B)-A*(x//B))
print(max(s))

Submission status: Time Limit Exceeded

Solution code:
import sys
input=sys.stdin.readline
A,B,N=map(int,input().split())
s=[0]
for x in range(N+1):
  t=((A*x)//B)-A*(x//B)
  if t>=max(s):
    s.append(t)
print(max(s))

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
ans = 0
for x in range(1, 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:
A,B,N=map(int,input().split())
s=[0]
for x in range(N+1):
  t=((A*x)//B)-A*(x//B)
  if t>=max(s):
    s.append(t)
print(max(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
a,b,n = map(int,input().split())
d = 0
i = 0
for i in range(1,n+1):
    c = int(a*i/b)-a*int(i/b)
    if c >= d:
        d = c
    else:
        i += 1
        if i > 1:
            print(int(a*(i-2)/b)-a*int((i-2)/b))
            sys.exit()
print(d)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def f(x):
    return (a*(x%b)-(a*b)%b)//b

ans = 0
for i in range(min(n+1,b+1)):
    ans = max(f(i),ans)
print(ans)

Submission status: Time Limit Exceeded

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


print(i)

Submission status: Time Limit Exceeded

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


def f(x):

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




ans = 0

for i in range(N, 0, -1):
    if f(i) > ans:
        ans = f(i)

print(ans)

Submission status: Time Limit Exceeded

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

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:
        break
    ans = tmp
print(ans)

Submission status: Time Limit Exceeded

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

if N < B:
  floor = int(A*N/B) - A*int(N/B)
elif N == B:
  floor = int(A*(N-1)/B) - A*int((N-1)/B)
else:
  floor = max([(int(A*(x-1)/B) - A*int((x-1)/B)) for x in range(B,N,B)])
print(floor)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

n = list(map(int,input().split()))
hikaku = 0

for x in range(1,n[2]+1):
    m = math.floor(n[0] * x // n[1]) - n[0] * math.floor(x // n[1])
    if hikaku < m:
        hikaku = m

print(hikaku)

Submission status: Time Limit Exceeded

Solution code:
import math

n = list(map(int,input().split()))
hikaku = 0

for x in range(1,n[2]+1):
    m = math.floor(n[0] * x / n[1]) - n[0] * math.floor(x / n[1])
    if hikaku < m:
        hikaku = m

print(hikaku)

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(n//2, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
    
print(pre)

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1//n, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
    
print(pre)

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
    
print(pre)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N+1):
    num = math.floor(A*i/B) - A*math.floor(i/B)
    if num > maxnum:
        maxnum = num
#    print(str(i) + ':' + str(num) + ' max is ' + str(maxnum))
print(maxnum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

maxresult = 0


#for x in range(n+1):
#    if (a * x * 1.0 // b) - a * (x * 1.0 // b) >= maxresult:
#        maxresult = int((a * x * 1.0 // b) - a * (x * 1.0 // b))

for x in range(n+1):
    if a * math.modf(x*1.0/b)[0] >= maxresult:
        maxresult = a * math.modf(x*1.0/b)[0]

print(int(maxresult))

Submission status: Time Limit Exceeded

Solution code:
import math

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

#maxresult = [(a * x * 1.0 // b) - a * (x * 1.0 // b) for x in range(n+1) if (a * x * 1.0 // b) - a * (x * 1.0 // b) >= maxresult]

maxresult = 0

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

print(maxresult)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(10**7):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = list(map(int, input().split()))
def function(a, b, x):
  return (a*x)//b - a*(x//b)
print(max([function(A, B, i) for i in range(max([1, N-N%B-1]), N+1)]))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = list(map(int, input().split()))
def function(a, b, x):
  return (a*x)//b - a*(x//b)
print(max([function(A, B, i) for i in range(max([1, N-B]), N+1)]))

Submission status: Time Limit Exceeded

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

a=min(B,N)
array=[]

for x in range(1,a+1):
  array.append(math.floor(A*x/B)-A*math.floor(x/B))
  
print(max(array))

Submission status: Time Limit Exceeded

Solution code:

def q4():
    A, B, N = [int(i) for i in input().split(" ")]
    m = 0
    for x in range(1, min(N + 1, B + 1)):
        m = max(m, (A * x) // B - A * (x // B))
    print(m)

q4()

Submission status: Time Limit Exceeded

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
res = f(a, b, n)
i = n - 1
cont = 0
while i > 0 and cont < 1e12:
    if f(a, b, i) > res:
        res = f(a, b, i)
        cont = 0
    else:
        cont += 1
    i -= 1
print(res)

Submission status: Time Limit Exceeded

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

mx = 0
for i in range(N+1):
    mx = max(mx, (A*i)//B-A*(i//B))
    
print(mx)

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)
else:
    print(math.floor(A * N / B) - A * math.floor(N / B))

Submission status: Time Limit Exceeded

Solution code:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = []
for x in range(1, N+1):
  s = A * x // B
  t = A * (x // B)
  a.append(s-t)
b = max(a)
print(b)

Submission status: Time Limit Exceeded

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

s = []
for i in range(n+1):
  x = ((a*i)//b) - a*(i//b)
  s.append(x)

print(max(s))

Submission status: Time Limit Exceeded

Solution code:
A, B ,N = map(int,input().split())
x = int(B / A) + 1
max = 0
while True:
  result = int((A*x)/B) - (A*int(x/B))
  if result > max:
    max = result
  if x == N:
    break
  x = x + 1
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

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

Submission status: Time Limit Exceeded

Solution code:
A, B ,N = map(int,input().split())
x = 0
max = 0
while True:
  result = int((A*x)/B) - (A*int(x/B))
  if result > max:
    max = result
  if x == N:
    break
  x = x + 1
print(max)

Submission status: Time Limit Exceeded

Solution code:

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(min(B, N + 1)):
    # if not x % B: continue
    res = ((A * (x % B)) - ((A * x) % B)) / B
    ans = max(ans, res)
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t = A * (x // B)
  if s - t > a:
    a = s - t
print(a)

Submission status: Time Limit Exceeded

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

mx = -1
count = 0
for x in range(1, N+1):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 300000000:
    break

print(mx)

Submission status: Time Limit Exceeded

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

mx = -1
count = 0
for x in range(1, N+1):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 343500000:
    break

print(mx)

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:
import math
a,b,n = map(int,input().split())
 
max_value = 0
 
for x in range(n+1):
  if x%b ==0:
    pass
  else:
    f = math.floor(a*x/b)-a*math.floor(x/b)
    if f >= max_value:
      max_value = f
    
print(max_value)

Submission status: Time Limit Exceeded

Solution code:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t_0 = x // B
  t = A * t_0
  u = s - t
  if u > a:
    a = u
print(a)