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:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    
    if n > 10 ** 6:
        for x in range(n, int(math.sqrt(n)), -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  
    for x in range(0,N+1):

        floor_num.append(int(A*x/B)-A*int(x/B))


print(max(floor_num))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    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

    print(output)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(Ma)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
answer = 0
for i in range(min(B,N+1)):
    mae = (A*i)//B
    usiro = A*(i//B)

    l = mae-usiro
    if l > answer:
        answer = l
print(answer)

Submission status: Time Limit Exceeded

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

max_s = []
j = 0
for i in range(n,0,-1):
    j += 1
    if j == 10**6.3:
        break
    else:
        num = int((a*i)/b) - a*int(i/b)
        max_s.append(num)
print(max(max_s))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(min(n, b-1), 0, -1):
  ans = max(ans, int((a*i)/b))
  if int((a*i)/b) < ans:
    break
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:

from math import floor, ceil, sqrt, factorial, gcd
def main():
    a, b, n = map(int, input().split())

    li = [(x/b)-floor(x/b) for x in range(1, n+1)]
    #yd = (x/b)-floor(x/b)
    x = li.index(max(li))+1
    ans = floor(a*x/b)-a*floor(x/b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
from fractions import gcd
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
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
print(int(maxi))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
inp1 = input()
inp1li = inp1.split()

A = int(inp1li[0])
B = int(inp1li[1])
N = int(inp1li[2])

anslist = []

while( N > 0):
  #if (N < B):
  #  print(N)
  #  break
  left = math.floor( (A * N) / B )
  right = math.floor(N / B) * A
  anslist.append(left - right)
  N -= 1
  
print(max(anslist))

  
#print("debug:left is {}".format(left))
#print("debug:right is {}".format(right))
#print(left - right)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = 0

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

print(m)

Submission status: Time Limit Exceeded

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

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

gokei = [int((A*(a+1))/B) - A*int((a+1)/B) for a in range(N)]
"""
for a in x:
  #floor(Ax/B)
  floor1 = int((A*a)/B)
  floor2 = int(a/B)
  test = floor1 - A * floor2
  gokei.append(test)
"""
gokei.sort(reverse=True)
print(gokei[0])

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

c = 0
ans = 0

if N < 1000001:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c

elif N < B:
  ans = int(A*N/B) - A*int(N/B)
      
else:
  count = B-1
  while N > count:
    c = int(A*count/B) - A*int(count/B)
    if ans < c:
      ans = c
    count += B
    
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N =list(map(int,input().split()))
def floor(a):
  if a.is_integer():
    return(int(a))
  else:
  	return(int(math.ceil(a)-1))
_che = 0
x=0
while x<=N:
  if not floor((A*x)/B) ==0:
    y = floor((A*x)/B) - A*floor(x/B)
    if _che < y:
      _che = y
  x+=1
print(_che)

Submission status: Time Limit Exceeded

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

ans = None

for _x in range(N):
    x = _x + 1
    s = int((A * x) / B) - A * int(x / B)
    if ans == None:
        ans = s
    elif s > ans:
        ans = s

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
import math


def solve(A: int, B: int, N: int):
    ans = 0
    for x in range(N+1):
        ans = max(ans, math.floor(A*x/B)-A*math.floor(x/B))

    print(ans)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

for x in range(N+1):
    if (int((A*x)/B)-A*int(x/B)) > a:
        a = (int((A*x)/B)-A*int(x/B))
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    
    if n > 10 ** 5:
        for x in range(n, int(math.sqrt(n)), -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

box = []

for num in range(N+1):
    X = math.floor(A*num/B) - A * math.floor(num/B)
    box.append(X)

print(max(box))

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
result = []
for i in range(10**8):
    result.append((a*n)//b - a*(n//b))
    n -= 1
    if n < 0:
        break
print(max(result))

Submission status: Time Limit Exceeded

Solution code:
from math import floor
if __name__ == "__main__":
    a, b, n = map(int, input().split())
    r = list()
    for i in range(1, n+1):
        r.append(floor(a*i // b) - a * floor(i//b))
    print(max(r))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
inputs = input().split(' ')
a = int(inputs[0])
b = int(inputs[1])
n = int(inputs[2])

output = 0
for x in range(1, n + 1):
    if x % b == 0:
        break
    buf = (a*x//b) - a*(x//b)
    if buf > output:
        output = buf

print(output)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans=0

for i in range(n+1):
  c=int(a*i/b)-a*int(i/b)
  if c>ans:
    ans=c
    
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

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

    max=0
    # for x in range(N+1):
    #     # ans=int(A*x/B)-A*int(x/B)
    #     min,_=math.modf(x/B)
    #     # ans=int(A*min)
    #     # print(min)
    #     if x==0:
    #         max=min
    #     elif min > max:
    #         max=min
    #     else:
    #         break

    max=0
    max_x=0
    reg=[]

    for x in range(N+1):
        rem = x%B
        if rem in reg:
            break
        else:
            reg.append(rem)
        if rem > max:
            max=rem
            max_x=x

    # min,_=math.modf(max_x/B)

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

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

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

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, N+1):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))

Submission status: Time Limit Exceeded

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

x = 0
max_score= -float('inf')
for x in range(N+1) :
    score = int(A*x/B) - A * int(x/B)
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Time Limit Exceeded

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

n = min(n, b)


mem = {}
m = 0
for x in range(1, n + 1):
    if mem.get(((a * x) % b, x % b)) is not None:
        break    
    else:
        c = math.floor(a * x / b) - a * math.floor(x / b)
        mem[((a * x) % b, x % b)] = 1
        m = max(m, c)
print(m)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

def fl(a,b,x):
	return math.floor(a*x/b)-a*math.floor(x/b)


# n,m,q = input2()
# abcd=[]
# A=[0]*n
# for i in range(q):
# 	abcd.append(input_array())

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

for i in range(0,n,b):
	ans=fl(a,b,i)
	if ans> b_ans:
		b_ans=ans
# if i<n:
# 	ans=fl(a,b,n)
# 	if ans> b_ans:
# 		b_ans=ans
print(b_ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Ansermax = 0

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

    Anser = 0

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

print(Ansermax)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
  import math
  A, B, N = map(int, input().split())
  p = 0
  tobi = B / A
  for i in range(int(N / tobi)):
    x = math.ceil(tobi * (i+1))
    score = ((A * x) // B) -  (A *(x // B))
    if score > p:
      p = score
    elif score < p:
      break
      
  print(p)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

max_s = []
j = 0
for i in range(n,0,-1):
    j += 1
    if j == 10**7:
        break
    else:
        num = int((a*i)/b) - a*int(i/b)
        max_s.append(num)
print(max(max_s))

Submission status: Time Limit Exceeded

Solution code:
from math import *
A,B,N=[int(i) for i in input().split()]
f = lambda k:floor(A*k/B)
k=0
mx=f(k)
while k<=B-1 and k<=N:
    if f(k)>mx:
        mx=f(k)
    k+=1
print(mx)

Submission status: Time Limit Exceeded

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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  
    for x in range(0,N+1):

        floor_num.append(int(A*x/B)-A*int(x/B))

    if N >=B:
        floor_num.append(int(A*(B-1)/B))

print(max(floor_num))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

A = int(A)
B = int(B)
N = int(N)

max_num = 0
for x in range(1, N+1):
    result = int(A*x/B) - A*int(x/B)
    if max_num < result:
        max_num = result

print(max_num)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
mx = 0
p = N
q = B

if B <= N:
    mx = math.floor(A / B * q) - math.floor(q / B) * A
    while mx == 0:
        q -= 1
else:
    mx = math.floor(A / B * p) - math.floor(p / B) * A
    while mx == 0:
        p -= 1

print(mx)

Submission status: Time Limit Exceeded

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

max_num = 0

x_list = [i for i in range(1, n + 1)]
for x in x_list:
    num = math.floor(a * x / b) - (a * math.floor(x / b))
    if max_num < num:
        max_num = num

print(max_num)

Submission status: Time Limit Exceeded

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

max = 0
for x in range(N+1):
    val = A * ((x / B) % 1) - ((A*x/B) % 1)
    # val = math.floor(A*x/B) - A*math.floor(x/B)
    if val > max:
        max = val
print(int(max))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def asahi(i):
  return int(a*i/b)-a*int(i/b)

l=list()
for m in range(n+1):
  l.append(asahi(m))
print(max(l))

Submission status: Time Limit Exceeded

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

max_ans=0
for x in reversed(range(N+1)):
        ans=math.floor(A*x/B)-(A*math.floor(x/B))
        if ans >= max_ans:
            max_ans=ans
print(max_ans)

Submission status: Time Limit Exceeded

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

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

print(max)

Submission status: Time Limit Exceeded

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

def fl(a,b,x):
	return math.floor(a*x/b)-a*math.floor(x/b)


# n,m,q = input2()
# abcd=[]
# A=[0]*n
# for i in range(q):
# 	abcd.append(input_array())

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

for i in range(0,n,b):
	ans=fl(a,b,i)
	# print(i)
	if ans> b_ans:
		b_ans=ans
if i<n:
	ans=fl(a,b,n)
	if ans> b_ans:
		b_ans=ans
print(b_ans)

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):
    if math.floor((x*A)/B)-A*(math.floor(x/B))>ans:
        ans = math.floor((x*A)/B)-A*(math.floor(x/B))
    if  math.floor((x*A)/B) <A*(math.floor(x/B)):
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
c = 0
t = -10
if N > 100000000:
    for i in range(100000000, N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 1100000000:
            print(c)
            break
        t = a
    else:
        print(c)
else:
    for i in range(N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 100000000:
            print(c)
            break
        t = a
    else:
        print(c)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
sys.setrecursionlimit(2000000)
# import itertools
# import statistics
# import numpy as np
# x = int(input())
a, b, n = list(map(int, input().split()))
ans = a*n//b - a*(n//b)

# for i in range(n, int(math.sqrt(n))-1, -1):
for i in range(n, int(pow(n, 0.75))-1, -1):
    if ans < a*i//b - a*(i//b):
        ans = a*i//b - a*(i//b)
    #print(ans, end=" ")
    #print(a*i//b - a*(i//b))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

for x in range(N+1):
    if (math.floor((A*x)/B)-A*math.floor(x/B)) > a:
        a = (math.floor((A*x)/B)-A*math.floor(x/B))
print(a)

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,0,-1):
  a = floor(A*x/B)-A*floor(x/B)
  if ans <= a:
    ans = a
print(ans)

Submission status: Time Limit Exceeded

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

x=0
ans = (math.floor(a * x / b) - a * math.floor(x / b))
while(True):
    if x>=n:break
    x+=1
    ans_tmp = (math.floor(a * x / b) - a * math.floor(x / b))
    if ans>0 and ans_tmp==0: break
    else: ans=ans_tmp

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = [0 for _ in range(b)]

for i in range(b):
    ans[i] = (a*i // b - a * (i // b))
    
ans = ans[:n+1] if n < b else ans

print(max(ans))

Submission status: Time Limit Exceeded

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

if B > N:
    print(A*N//B)
else:
    L = []
    for x in range(N):
        L.append(A*x//B-A*(x//B))
    print(max(L))

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int, input().split())
maxim = 0
theor = math.floor((b-1) * a / b)

for x in range(n, 0, -1):
    tmp = math.floor(a * x / b) - a * math.floor(x / b)
    if maxim < tmp:
        maxim = tmp
        if maxim == theor:
            break

print(maxim)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

tmp = 0
a = 0
i = 0
for i in range(B - 1, N + 1, B):
    if (s := (A * i) // B - A * (a)) > 0:
        tmp = max(s, tmp)
    else:
        break

if i >= N - B:
    for i in range(N, N - N % B - 1, -1):
        if (s := (A * i) // B - A * (i // B)) > 0:
            tmp = max(s, tmp)
        else:
            break

print(tmp)

Submission status: Time Limit Exceeded

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

max_num = -1
max_ans = -1
for x in range(n+1):
  tmp = ((x / b) - (x // b)) * a
  if max_num < tmp:
    max_num = tmp
    max_ans = a * x / b // 1 - a * (x / b // 1)
  else:
    break
    
print(int(max_ans))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

def iin(): return int(input())
def iln(): return list(map(int, input().split()))

def solve(A,B,N):
    curr_x = 1
    max_so_far = 0
    max_x = 0
    ERROR = 1/(10**3)
    while curr_x <= N:
        curr_res = int((A * curr_x)/B) - (A * int(curr_x / B))
        if max_so_far < curr_res:
            max_so_far = curr_res
            max_x = curr_x
        curr_x += 1
        prev_res = curr_res


    return max_so_far

A, B, N = iln()
print(solve(A,B,N))

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
ans=0
t=min(B+1,N+1)
t_min=min(0,t-100)
for x in range(t_min,t):
    a=int(A*x/B)
    b=A * int(x/B)
    ans=max(ans,a-b)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
list = []

if N >= 10000000:
    for i in range(N-10000000,N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Time Limit Exceeded

Solution code:
from math import floor
from collections import deque

def main():
    A,B,N=map(int,input().split())
    d=deque()
    ok=False
    
    for x in range(N+1):
        tmp=floor(A*x/B)-A*floor(x/B)
        if tmp<floor(A*(x-1)/B)-A*floor((x-1)/B) and x>=1:
            ok=True
            break
        
        d.append(tmp)
        
    
    print(d[-1])
    
if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

l = []
for x in range(N+1):
    Z = (A * x) // B - A * (x // B)
    l += [Z]
print(max(l))