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:
#d
a, b, n = map(int, input().split())

def keisan(a, b, x):
    return ((a*x)//b)-a*(x//b)

m = min(b,n)
print(max(list(map(lambda y: keisan(a, b, y) , range(0,m+1)))))

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):
  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:
def main():
	a,b,n = map(int,input().split())
	
	x = 0
	c = 0
	m = int((a*x)/b) - (a* int(x/b))
	while x < n:
		# print(x)
		x += 1
		if m == 0 and (int( (a*(x)) /b) - (a* int((x)/b))) != 0:
			# print("if YES")
			c += 1
			if c > 1:
				break
		m = max(m, int((a*x)/b) - (a* int(x/b)))
	print(m)

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

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

def numerical_diff(f, x, h=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

# def f_diff(f, x, h=B):
#     return f(x + h) - f(x)

def gradient_descent(f, initial, learning_rate=1, steps=10 ** 4):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for step in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = 0
        count = 1
        while grad == 0:
            h = B * count
            grad = numerical_diff(f, x, h=h)
            count += 1
        x -= learning_rate * grad
        if x < 0:
            x = 0
        elif x > N:
            x = N

    # 最終的な位置を返す
    return f(x)

ma = 0
for x in range(B):
    if x > N: break
    # ini = random.randrange(N + 1)
    # tmp = gradient_descent(f, ini)
    tmp = f(x)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(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:
import sys
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

def numerical_diff(f, x, h=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

def gradient_descent(f, initial, learning_rate=1, steps=10 ** 5):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for step in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        x -= learning_rate * grad
        if x < 0:
            x = 0
        elif x > N:
            x = N

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(10 ** 2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
a,b,n = map(int,input().split())
ans = -99999999999999
for i in range(1,n+1):
    tmp = floor(a*i/b) - a * floor(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 = 0
for x in range(1, N+1):
    term1 = math.floor(A*x/B)
    term2 = A * math.floor(x/B)
    temp = term1 - term2

    # print("x: {}, temp: {}, term1: {}, term2: {}".format(x, temp, term1, term2))

    ans = max(ans, temp)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x=N
result=[]
maxr=0
for x in reversed(range(1,N+1)):
    xb=x/B
    r=0 if xb < 1 else A*floor(xb)
    l=floor(A*xb)
    ans=l-r
    # print(xb,l,r,ans)
    result.append(ans)
    if len(result) == 1:
        maxr = ans 
    if len(result) > 1 and max(result) == maxr:
        pass

print(max(result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans_dict = {}
for x in range(N + 1):
    if (A * x) // B >= (A * (x // B)):
        ans_dict.setdefault((((A * x) // B) - (A * (x // B))), x)
    else:
        break


print(max(ans_dict))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x=N
result=[]
maxr=0
for x in reversed(range(1,N+1)):
    r=0 if x<B else A*floor(x/B)
    ans=floor(A*x/B)-r
    result.append(ans)
    if len(result) == 1:
        maxr = ans 
    if len(result) > 1 and max(result) == maxr:
        pass

print(max(result))

Submission status: Time Limit Exceeded

Solution code:
li=list(input().split())
a=int(li[0])
b=int(li[1])
n=int(li[2])
ans=int(a*0/b)-a*int(0/b)
for x in range(n+1):
    s=int(a*x/b)-a*int(x/b)
    if s>ans:
        ans=s
    if x>b:
        break
print(ans)

Submission status: Time Limit Exceeded

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

nb=n//b

xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
    for xb in range(nb):
        xv=(a*xb*b+a*(b-1))//b-a*xb
        xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)

Submission status: Time Limit Exceeded

Solution code:

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

nb=n//b

xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
    for xb in range(nb):
        xv=(a*xb*b+a*(b-1))//b-a*xb
        xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = 0
l = []

for i in range(1,N+1):
	x += 1
	answer = (A*x//B) - A*(x//B)
	l.append(answer)


print(max(l))

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
count = 0
Score = list()
i = 1
while i <= N:
  score = math.floor((A*i)/B) - A * math.floor(i/B)
  Score.append(score)
  i += 1
print(max(Score))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x=N
result=[]
maxr=0
for x in reversed(range(1,N+1)):
    ans=floor(A*x/B)-A*floor(x/B)
    result.append(ans)
    if len(result) == 1:
        maxr = ans 
    if len(result) > 1 and max(result) == maxr:
        pass

print(max(result))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans_dict = {}
for x in range(N + 1):
    ans_dict.setdefault((((A * x) // B) - (A * (x // B))), x)


print(max(ans_dict))

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
count = 0
Score = list()
i = 1
while i <= N:
  score = math.floor((A*i)/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    break
  i += 1
print(max(Score))

Submission status: Time Limit Exceeded

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

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

    print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
count = 0
Score = list()
i = 1
while i <= N:
  score = math.floor((A*i)/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    count += 1
  if count ==10:
    break
  i += 1
print(max(Score))

Submission status: Time Limit Exceeded

Solution code:
import math

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

print(max([math.floor(a*i / b) - a * math.floor(i / b)  for i in range(1, b + 1 if b < n else n + 1)]))

Submission status: Time Limit Exceeded

Solution code:
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]
ma=max

from math import floor as f

a,b,n=ent()
res=0
for i in range(1,n+1):
    res=ma(res,f(a*i/b)-a*f(i/b))
print(res)

Submission status: Time Limit Exceeded

Solution code:
import math


def main():
    a,b,n = map(int,input().split())
    m = math.floor(a * 0 /b) - a * math.floor(0/b)
    for i in range(1,min(b-1,n)+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)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main(n,m,q):
    l=[]
    for i in range(1,q+1):
        j=(n*i)//m-n*(i//m)
        l.append(j)
    l=sorted(l)
    print(l[-1])
n,m,q=map(int,input().split())
main(n,m,q)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
if n<b:
    max=math.floor(a*n/b)
else:
    #b<=n
    max=math.floor(a*(b-1)/b)
    for i in range(b,n+1):
        s2=math.floor(a*((1/b)-i//b))
        if max<s2:
            max=s2

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

Submission status: Time Limit Exceeded

Solution code:
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(min(b,n)//2,min(b+1,n+1)):
        left = int(a*x/b)
        right = a * int(x/b)
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,min(b+1,n+1)):
        left = int(a*x/b)
        right = a * int(x/b)
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


print(max(ans_list))

Submission status: Time Limit Exceeded

Solution code:
import math


def main():
    a,b,n = map(int,input().split())
    m = math.floor(a * 0 /b) - a * math.floor(0/b)
    for i in range(1,n+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)
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

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

Score = list()
i = 1
while True:
  score = math.floor(A*i/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    break
print(max(Score))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

print(int(z))

Submission status: Time Limit Exceeded

Solution code:
import math
import random
import decimal

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

decimal.getcontext().prec = 6
max = quick(decimal.Decimal(N))
for i in range(800000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(decimal.Decimal(ran))
  if(max < tem):
    max = tem

print(max)

Submission status: Time Limit Exceeded

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

l = []
if N < B:
    for x in range(N+1):
        l.append(math.floor(A*x/B) - A*math.floor(x/B))
else:
    for x in range(B):
        l.append(math.floor(A*x/B) - A*math.floor(x/B))

print(max(l))
# print(l)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
l = list(map(int,input().split()))
a = l[0]
b = l[1]
n = l[2]

def floor(a,b,x):
    p = (a*x)//b - a*(x//b)
    return p

max = 0
if n <= b-1:
    max = floor(a,b,n)
else:
    for i in range(b-1,n+1,b):
        c = floor(a,b,i)
        if c >= max:
            max = c

print(max)

Submission status: Time Limit Exceeded

Solution code:
l = list(map(int,input().split()))
a = l[0]
b = l[1]
n = l[2]

def floor(a,b,x):
    p = (a*x)//b - a*(x//b)
    return p

max = 0
if n < b-1:
    max = floor(a,b,n)
else:
    for i in range(b-1,n+1,b):
        c = floor(a,b,i)
        if c >= max:
            max = c

print(max)

Submission status: Time Limit Exceeded

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

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

import math

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

if __name__ == '__main__':
    a, b, n = map(int, input().split())
    if b > n:
        x = n
        m = calc(a, b, x)
    else:
        m = 0
        k = 1
        while b * k <= n:
            v = calc(a, b, b * k - 1)
            m = max(m, v)
            k += 1
    print(m)

Submission status: Time Limit Exceeded

Solution code:
import copy
s = input().split()
A = int(s[0])
B = int(s[1])
N = int(s[2])
s = 0

if B > N:
	for i in reversed(range(N+1)):
		y = int(A * i / B) - A * int(i / B)
		# print(y)
		if s <= y:
			s = copy.copy(y)
		else:
			break
else:
	for i in reversed(range(B+1)):
		y = int(A * i / B) - A * int(i / B)
		# print(y)
		if s <= y:
			s = copy.copy(y)
		else:
			break

print(s)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import fractions
import copy
import bisect
import math
import numpy as np

#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline


N=3
M=3
i=0
j=0
k=0
n=3
r=1
a=[0]*5
b=[]
#n=int(input())
#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
pre=0

"1行1つの整数を入力を取得し、整数と取得する"
A,B,N=map(int, input().split(" "))
syo=len(str(N))
if syo <10**4:
 for i in range(N+1):
    k=((A*i)//B)-A*(i//B)
    if pre > k :
        print(pre)
        sys.exit()
    pre=k
    b.append(k)
    k=0
for i in range(N+1):
        k=(A*(i+10**(syo-1)))//B-A*((i+10**(syo-1))//B)
        #print(pre,k)
        if pre > k:
            print(pre)
            sys.exit()
        pre=k
        b.append(k)
        k=0

print(max(b))
#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation

'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''





########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=[int(x) for x in input().rstrip().split()]
ans=0
now=0
aa=0

cnt=0
while(True):
  if 0<int(cnt/B):
    break
  else:
    cnt+=1
cnt=cnt-1

if N<B:
  print(int(A*N/B)-A*int(N/B))
else:
  print(int(A*cnt/B)-A*int(cnt/B))

Submission status: Time Limit Exceeded

Solution code:
import math

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

l = [0]

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

Submission status: Time Limit Exceeded

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

print(max(box))

Submission status: Time Limit Exceeded

Solution code:
l = list(map(int,input().split()))
a = l[0]
b = l[1]
n = l[2]

def floor(a,b,x):
    p = (a*x)//b - a*(x//b)
    return p

max = 0
if n < b-1:
    for i in range(n+1):
        c = floor(a,b,i)
        if c >= max:
            max = c
else:
    for i in range(b-1,n+1,b):
        c = floor(a,b,i)
        if c >= max:
            max = c

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
if b<n:
    n=b
for i in range(1,n+1):
    if i<b:
        s=math.floor(a*i/b)
    else:
        p=i//b
        q=i/b-p
        z=q*a
        s=math.floor(a*((1/b)-i//b))
    if s>max:
        max=s
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
ans = []
for x in range(0, 10**3):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
for x in range(N-10**7, 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 = map(int,input().split())
ans = 0

for i in range(1,N+1):

    pre = (A*i//B) - A * (i//B)

    if(pre<ans):
        break

    else:
        ans = pre


print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
ans = list()
x = 1
while x <= N:
    ans.append(math.floor(A*x/B)-A*math.floor(x/B))
    if x+1 <= N and ans[x-1] > (math.floor(A*(x+1)/B)-A*math.floor((x+1)/B)):
        break
    else:
      x += 1
print(max(ans))

Submission status: Time Limit Exceeded

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

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)
count = 0
same = 0
# print(ans)
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)
        if count == 1:
            print(ans)
            exit()
    elif a*i//b - a*(i//b) == 0:
        count += 1
    elif a*i//b - a*(i//b) == ans:
        same += 1
    if same > b:
        print(ans)
        exit()

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

l = []
if N < B:
    for x in range(N+1):
        l.append(math.floor(A*x/B) - A*math.floor(x/B))
else:
    for x in range(B+1):
        l.append(math.floor(A*x/B) - A*math.floor(x/B))

print(max(l))
# print(l)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
if b<n:
    n=b
for i in range(1,n+1):
    if i<b:
        s=math.floor(a*i/b)
    else:
        p=i//b
        q=i/b-p
        z=q*a
        s=math.floor(z)
    if s>max:
        max=s
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

def main(A, B, N):
    answer = 0
    for x in range(N + 1):
        cand = math.floor(A * x / B) - A * math.floor(x / B)
        answer = max(answer, cand)
    print(answer)



if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    # A, B, N = 5, 7, 4
    main(A, B, N)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Ansermax = 0

if b < N :
    N = b
    
for x in range(N+1):

    Anser = 0

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

print(Ansermax)

Submission status: Time Limit Exceeded

Solution code:

# floor(Ax/B)−A×floor(x/B)
a,b,n=map(int,input().split())
x = 0
ans=[]
ans.append(0)
while True:
    Ax = a*x
    A = int((Ax/b))
    B = -a*int(x/b)
    ans.append(A+B)
    if x >= n:
        print(max(ans))
        break
    if ans[x] > ans[x+1]:
        print(ans[x])
        break
    x+=1

Submission status: Time Limit Exceeded

Solution code:
A, B, N = [int(i) for i in input().split(" ")]
ans = 0
idx = 0
for x in range(1, 10000000):
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

for x in range(B, B-10000000, -1):
    if x < 0:
        break
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

print(ans)

Submission status: Time Limit Exceeded

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

if __name__ == '__main__':
    main()