Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Time Limit Exceeded

Solution code:
import math

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

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)


max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
def resolve():
    a,b,n=map(int,input().split())
    c=0
    for i in range(n):
        if __name__ == '__main__':
            y=math.floor(a*(i+1)/b)-a*math.floor((i+1)/b)
            c=max(y,c)
    print(c)
    
resolve()

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    while b*i-1<=n:
        j=b*i-1
        num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
        i+=1
print(num)

Submission status: Time Limit Exceeded

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

print(max(m))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import math
M = 0
for x in range(max(N-10000000,0),N+1):
    Z = math.floor(A * x / B) - A * math.floor(x / B)
    if M < Z:
        M = Z
print(M)

Submission status: Time Limit Exceeded

Solution code:
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	for i in range(n,0,-1):
		f = math.floor((a*i)/b)
		s = math.floor(i/b)
		temp = int(f) - (a*int(s))
		if(temp > ans):
			ans = temp
	print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

L = []
for i in range(N):
  L.append(int(A*(i+1)/B)-A*int((i+1)/B))

print(max(L))

Submission status: Time Limit Exceeded

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

max = -1
x = 0

while(x < n):
    x += 1
    new = math.floor(a*x/b) - a * math.floor(x/b)
    #print(math.floor(a*x/b), " - ",  a * math.floor(x/b))
    #print(new)
    if max < new:
        max = new


print(max)

Submission status: Time Limit Exceeded

Solution code:
# Code for D - Floor Function
# Use input() to fetch data from STDIN
from math import floor

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

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

logical_max = f(-1)

max_result = 0
for x in range(n):
    x = x + 1
    r = floor(a * x / b) - a * floor(x / b)
    if r > max_result:
        max_result = r

print(min(logical_max, max_result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, raw_input().split())
def f(x):
    return int(A*x/float(B)) - A * int(x/float(B))

score = 0
max_score = 0

for x in xrange(N+1):
    score = f(x)
    if score >= max_score:
        max_score = score
    else:
        break

print max_score

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
sys.setrecursionlimit(2000000)

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):
    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())
k=30000000

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)


max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Time Limit Exceeded

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

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

print(max(tmp))

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,n = [int(x) for x in input().split()]
# print(A,B,n)
max_ = 0
for x in range(n+1):
    # hoge = math.floor(A*x/B) - A*×*(math.floor(x/B))
    hoge = math.floor(A*x/B) - A*(math.floor(x/B))
    # print(hoge)
    if hoge >= max_:
        max_ = hoge
print(max_)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

res = 0
if N < B:
    res = (A * N) // B
else:
    i = B - 1
    while i < N + 1:
        a = ((A * i) // B) - (A * (i // B))
        if res <= a:
            res = a
        else:
            break
        i += 1

print(res)

Submission status: Time Limit Exceeded

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

import math

ans=0
if N < B:
  end = N + 1
else:
  end = B

for x in range(1,end):
  tmp=math.floor(A*x/B) - A * math.floor(x/B)
  if tmp > ans:
    ans = tmp

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

A,B,N = inpl()
x = 0
for i in range(0,N+1):
  if B > i:
    x = i
  else:
    break
    
print(A*x//B)

Submission status: Time Limit Exceeded

Solution code:
import math


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

print(max)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
minimum=min(N-3,0)
for i in range(minimum,N+1):
  list_ans.append(int(A*i/B)-A*int(i/B))
print(int(max(list_ans)))

Submission status: Time Limit Exceeded

Solution code:
import math
def inputOneLine():
	global S
	S=input()
	return S.split(' ')

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

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

	#print(i)
	#print(printn(ans11) + \
	#printn(ans1)  + \
	#printn(ans22)  + \
	#printn(ans2)  + \
	#printn(ans3))

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
pp =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if sec == True and tmp != 0:
        pp =True
    if tmp == 0:
        if sec ==True and pp ==True:
            break
        else:
            sec =True
    
print(maxn)

Submission status: Time Limit Exceeded

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

x = 0
maxi = -1
while x <= n:
    if int(a*x/b) - a*int(x/b) >= maxi:
        maxi = int(a*x/b) - a*int(x/b)
    x += 1

print(maxi)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)


max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

if N < B:
    print((A*N)//B)
    exit()

qa, ra = divmod(A, B)
ans = 0
rx = 0

for x in range(N+1):
    rx = max(rx, x%B)
    if rx == B-1:
        break

print(qa*rx + (ra*rx)//B)

Submission status: Time Limit Exceeded

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

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
A,B,N = MI()

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
minimum=min(N-10,0)
for i in range(minimum,N+1):
  list_ans.append(int(A*i/B)-A*int(i/B))
print(int(max(list_ans)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

list=0
for i in range(1,N+1):
  if not N*A<B:
    c=((A*i)//B)-(A*(i//B))
    if list<c:
      list=c
print(list)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

max_v = 0
for x in range(min(B,N+1)):
    max_v = max(max_v, calc(x))

print(max_v)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())  # x = 1, y = 2

max_y = 0
for x in range(n + 1):
    y = ((x * a / b) // 1) - a * ((x / b) // 1)
    if max_y < y:
        max_y = y


print(int(max_y))

Submission status: Time Limit Exceeded

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

import math

x = n
tmp1 = math.floor(a*x/b) - a*math.floor(x/b)
ret = tmp1

if n//b == 0:
    print(tmp1)
else:
    q, _ = divmod(n, b)
    for i in range(1,q+1):
        x = i*b-1
        tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
        ret = max(ret, tmp2)
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
left = math.floor(A/B)
if N > B:
    li = [i for i in range(left,B+1) ]
else:
    li = [i for i in range(left,N+1) ]
m = 0
for i in li:
    m = max(m,math.floor((A*i)/B)-A*math.floor(i/B))
print(m)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################


def main():
    A,B,N=map(int,input().split())
    G=[]
    prev=-inf
    for x in range(0,N+1):
        num=(A*x)//B - A*(x//B)
        if prev>num:
            break
        else:
            prev=num
            G.append(num)
    ans=max(G)
    print(ans)
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in reversed(range(n+1)):
    if i<b:
        print(math.floor(a*i/b))
        break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor

a,b,n = map(int, input().split())
mx = 0
for i in range(n+1):
  v = floor(a*i/b) - a*floor(i/b)
  if v < mx:
    break
  else:
    mx = v
print(mx)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
minimum=min(N-20,0)
for i in range(minimum,N+1):
  list_ans.append(int(A*i/B)-A*int(i/B))
print(int(max(list_ans)))

Submission status: Time Limit Exceeded

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

x = 0
maxi = -1
while x <= n:
    if int(a*x/b) - a*int(x/b) >= maxi:
        maxi = int(a*x/b) - a*int(x/b)
        x += 1

print(maxi)

Submission status: Time Limit Exceeded

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

import math

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

maxnum = 0

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


print(maxnum)

Submission status: Time Limit Exceeded

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    a, b, n = map(int, input().split())
    max = 0
    for x in range(1, n+1):
        ans = math.floor(a*x/b)-a*(math.floor(x/b))
        if max < ans:
            max = ans
    print(max)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    a, b, n = map(int, input().split())
    m = 0
    for _,x in enumerate(range(1, n+1)):
        p = (a*x)//b - a*(x//b)
        if m < p:
            m = p
    print(m)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

a, b, n = map(int, input().split())
# a, b, n = 4628, 3261783, 3421

max_num = -99999999999999999999999

for i in range(n):
    x = i + 1
    num = floor(a*x / b) - a * floor(x / b)
    
    if num > max_num:
        max_num = num
        
print(max_num)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def floor(m):
    return int(m)

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

print(max(List))

Submission status: Time Limit Exceeded

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
minimum=min(N-100,0)
for i in range(minimum,N+1):
  list_ans.append(int(A*i/B)-A*int(i/B))
print(int(max(list_ans)))

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
max = -9999999999
for i in range(1,n+1):
    buf = a*(i%b)-(a*i)%b 
    if buf > max:
        max = buf

print(int(max/b))

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8
def main():
    import math

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
max = -1
same_cnt = 0

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

    if max <= ans:
        if max == ans:
            same_cnt += 1
        else:
            same_cnt = 0
        max = ans
    else:
        break

    if same_cnt > (N // 10):
        break

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, N = list(map(int, input().split()))


# 関数の定義
def func(x: int) -> int:
    return math.floor(A*x/B) - A*math.floor(x/B)


# 求解処理
result = 0
for x in range(min(N, B-1), N+1, B):
    result = max(result, func(x))

# 結果出力
print(result)

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

Submission status: Time Limit Exceeded

Solution code:
numbers = list(map(int, input().split()))
maxnum = 0
for i in range(numbers[2]+1):
  buf = int((numbers[0] * i)/numbers[1]) - numbers[0] * int(i/numbers[1])
  if buf >= maxnum:
    maxnum = buf
print(maxnum)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = list(map(int, input().split()))
def floor(t):
    if t == 0 or t == int(t):
        return t
    return math.floor(t)

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
arr = input().split(" ")
A = int(arr[0])
B = int(arr[1])
N = int(arr[2])
s=[]
for x in range(0,N+1):
    y=int((A*x)/B)
    z=int(x/B)
    p=y-A*z
    s.append(p)
print(max(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(m)

Submission status: Time Limit Exceeded

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = (int(x) for x in input().split())

ans = 0

for x in range(n + 1):
    temp = math.floor(a * x / b) - a * math.floor(x / b)

    if ans <= temp :
        ans = temp

print(ans)

Submission status: Time Limit Exceeded

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

list=0
for i in range(1,N+1):
  c=((A*i)//B)-(A*(i//B))
  if list<c:
    list=c
print(list)