Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
import 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 = 1e-4
    return (f(x + h) - f(x - h)) / (2 * h)

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

    # 所定の回数を繰り返す
    for _ in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= learning_rate * grad

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

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

print(ma)

Submission status: Wrong Answer

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

if B<=A:
    M = min(B, N+1)
    ans = 0
    for x in range(M):
        ans = max(ans, A*x//B-x//B*A)
else:
    ans = A*N//B

print(ans)

Submission status: Wrong Answer

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 or i > 100000000:
        print(c)
        break
    t = a
else:
    print(c)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
x = ((N + 1) // B) * B - 1 if (N + 1) // B else N
assert x <= N, "error"
print(int(A * x / B) - A * int(x / B))

Submission status: Wrong Answer

Solution code:
A, B, N = list(map(int,input().split()))
def max_val(a, b, n):
  if b-1 > n:
    x = n
  else:
    x = (b-1)
  return max( int(a*x/b) - a*int(x/b), int(a*n/b) - a*int(n/b)) 
print(max_val(A,B,N))

Submission status: Wrong Answer

Solution code:
import math
line = input()
a, b, n = line.split(" ")
a, b, n = int(a), int(b), int(n)
# ans = 0


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

ans1 = math.floor((a*n)/b) - math.floor(n/b)
ans2 = math.floor((a*n-1)/b) - math.floor(n-1/b)
print(max(ans1, ans2))

Submission status: Wrong Answer

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 == 340000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
Max = 0
e = 1/b
ae = a*e
axb = 0
xb = 0
temp = 0
h_cut = 0
u_cut = 0
for i in range(n):
  axb += ae
  xb += e
  h_cut = axb-int(axb)
  u_cut = (xb-int(xb))*a
  temp = int(u_cut-h_cut)
  Max = max(Max, temp)
else:
  print(Max)

Submission status: Wrong Answer

Solution code:
from decimal import *
getcontext().prec = 30

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

if B == N:
    ans = Decimal(A - 1)
elif B < N:
    ans = Decimal(A - 1)
else:
    ans = int(Decimal(A)*Decimal(N)/Decimal(B))-Decimal(A)*int(Decimal(N)/Decimal(B))
    #print(int(N*A/B)-A*int(N/B))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    ans = math.floor((A * N) / B) - A * math.floor(N / B)
    print(ans)
else:
    if B == 1:
        underB = 0
    else:
        underB = math.floor((A * (B - 1)) / B) - A * math.floor((B - 1) / B)
    eqB = 0
    eqN = math.floor((A * N) / B) - A * math.floor(N / B)
    print(max(underB, eqB, eqN))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N<B/A:
  ans=0
elif ceil(B/A)<=N<A:
  ans= (A*N)//B
else:
  ans = max(1,(A*N)//B)

print(ans)

Submission status: Wrong Answer

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

def f(n):
    return int(A*n/B) - A*int(n/B)

ans = f(N)
for n in range(N-1,N-10**6-5,-1):
    if n <= 0: break
    ans = max(ans, f(n))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    A,B,N = map(int, input().split())
    nax = -10
    for i in range(min(A,N)+1):
        id = B/A*i
        if (id > N):
            break
        ans = floor(A*id/ B) - A * (floor(id/B))
        nax = max(nax,ans)
    print(nax)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n, max(-1, n - 2 * a - 1), -1):
    ans = max(ans, floor(a * x / b) - a * floor(x / b))

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

print(max(int(ans), 0))

Submission status: Wrong Answer

Solution code:
def f(a, b, n):
    return (a*n) // b - a*(n//b)


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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans1 = -111111
if n >= b:
    ans1 = (a * b)//b - a*(b//b)
ans2 = (a * n)//b - a*(n//b)
print(max(ans1, ans2))

Submission status: Wrong Answer

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

if (N <= B):
    print(((A * (N)) // B) - (A * ((N) // B)))
elif(N > B):
    print(((A * (B - 1)) // B) - (A * ((B - 1) // B)))

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
i = c
print(int(a * i / b) - a * int(i / b))

Submission status: Wrong Answer

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)
    x = q*b-1
    tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
    ret = max(ret, tmp2)
    print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def target(x):
    return (A * x) // B - A * (x // B)


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

left = 1
right = N

while right - left > 1:
    mid = (left + right) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))

Submission status: Wrong Answer

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

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

#print(max(li))

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
X=(N//B)*B-1
if X+B<=N:
  X=X+B
ans=(A*N)//B-A*(N//B)
ans=max(ans,(A*X)//B-A*(X//B))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, 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 == 330000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
import math

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

n1 = max(0, n//b*b-1)
ans = max(math.floor(a*n/b)-a*math.floor(n/b), math.floor(a*n1/b)-a*math.floor(n1/b))

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    
    for x in range(n, a, -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: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    def f(m):
        return (A * m) // B - A * (m // B)

    l = f(0)
    e = f(N)

    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False
    def isOK2(mid):
        if f(mid) - e >= 0:
            return True
        else:
            return False

    ok = 0
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    ok = N
    ng = 0

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK2(mid):
            ok = mid
        else:
            ng = mid

    ans = max(ans, l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n%b)
else:
    maxT = 0
    i = n
    while i >= n-1000 and i>= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    print(maxT)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

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

print(max(a*(B-1)-k-1, f(N)) if n>0 else f(N))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0

k=n//b
if k>0:
	j=b
else:
	j=n

for i in range(j):
	cnt=max(cnt,(a*(j)//b-a*((j)//b)))
print(cnt)

Submission status: Wrong Answer

Solution code:
ABN = [int(x) for x in input().split()]
y=0
n=[]

if ABN[2]>=ABN[1]-1:
  y=ABN[0]-int(ABN[0]/ABN[1]+1)
else:
  y=int(ABN[0]*ABN[2]/ABN[1])-ABN[0]*int(ABN[2]/ABN[1])
  
print(y)

Submission status: Wrong Answer

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

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

ans =max(floor(A,B,N),floor(A,B,N*(N//B)),floor(A,B,N*(N//B)),floor(A,B,B*(A*N//B)//A))


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

#X=int(input())
# a=int(input())
A,B,N=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

s=N//B

x=s*B-1
if x < 0:
  x=N

#print(x)

#ans = math.floor(A*x/B) - A * math.floor(x/B)
ans = math.floor(A/B*x) - A * math.floor(x/B)
ans1 = math.floor(A/B*N) - A * math.floor(N/B)

if ans1 > ans:
  ans = ans1

#print(a,b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math


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

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

    max_value = -1
    max_x = -1

    for i in range(1, int(N / B) + 1):
        v = target(i * B)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_value = v

    for i in range(1, int(N / (B / A)) + 1):
        v = target(i * B / A)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_value = v

    # print(max_x)
    print(max_value)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split(" "))
x = n - 1 if n % b == 0 else n
print(math.floor(a * x / b) - a * math.floor(x / b))

Submission status: Wrong Answer

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 >= 500:
    for i in range(N-500,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: Wrong Answer

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 = 1e-4
    return (f(x + h) - f(x - h)) / (2 * h)

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

    # 所定の回数を繰り返す
    for _ in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= learning_rate * grad

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

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

print(ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

if __name__ == '__main__':
    a, b, n = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    old = 0
    x = b - 1
    print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Wrong Answer

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

    f = lambda x: int(A*x/B) - A * int(x / B)

    if B == 1:
        print(0)
    else:
        ans = 0
        x = B * (N // B) - 1 if N >= B-1 else N
        ans = max(f(x), ans)
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

if a == 1 or b == 1:
    print(0)
    exit()
    

l_n = n - 1

print(math.floor(a*n/b)- a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
a1=int((a*n)/b)-a*int(n/b)
i=int((n+1)/b)
if i!=0:
    a2=int((a*(i*b-1))/b)-a*int((i*b-1)/b)
    print(max(a1,a2))
else:
    print(a1)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0

for x in range(1, A[2]+1):
  if i_max < (A[0]*x//A[1]-A[0]*(x//A[1])):
    i_max = (A[0]*x//A[1]-A[0]*(x//A[1]))
    i_count = x
    
print(i_count)

Submission status: Wrong Answer

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

import math

alist=[]
xlist=[]
x=0
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)
if N>=B:
    x=B-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)

    x=B*(N//B)-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)

x=N
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)

print(max(alist))

Submission status: Wrong Answer

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 == 350000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
import bisect  # 二分探索の公式のライブラリをimportする
# A, B, N = map(int, input().split())
# ans = (int(A*N/B) - A*int(N/B))
# # シミュレーション
# for i in range(max(N-1000005, 0), N+1):
#     ans = max(ans, int(A*i/B)-A*int(i/B))
# print(ans)


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

l = 0  # 最初の下界
r = N+1  # 最初の上界
ans = 0
while r - l > 1:  # rとlが交わることがあれば終了
    mid = (l+r) // 2  # 中央値, 選ぶ候補になっている値
    tmp = int(A*mid/B) - A*int(mid/B)
    if tmp >= ans:
        ans = tmp
        l = mid  # 下界をあげる
    else:
        r = mid  # 上界を下げる
#     print(l, r)
# print(l, r)
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    A,B,N = isRaw()
    a1 = int((A*N)/B)-A*int(N/B)
    if N<B:
        return a1
    else:
        res = B-1
        a2 = int((A*res)/B)-A*int(res/B)
        if A<=B:
            return max(a1,a2,0)
        return max(a1, a2, 0)
        
    
if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

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

if a <= n:
    print(int((b-1)*a/b))
else:
    print(n*a//b)

Submission status: Wrong Answer

Solution code:
A, B, N = list(map(int,input().split()))
def max_val(a, b, n):
  if b-1 > n+1:
    x = n
  else:
    x = (b-1)
  return max( int(a*x/b) - a*int(x/b), int(a*n/b) - a*int(n/b)) 
print(max_val(A,B,N))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x,a=a,b=b):
  return (a*x//b) -a*(x//b)
print(f(b-1) if b<n else f(n))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

var = N//B
ans = -1

if var != 0:
    for i in range(N, -1, N//B):
        tmp = math.floor(A*i/B) - A*math.floor(i/B)
        ans = max(ans, tmp)
else:
    ans = math.floor(A*N/B) - A*math.floor(N/B)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
a, b, n, = map(int, input().split())
if n < b:
    print(int(a*(n)/b)-a*int((n)/b))
    sys.exit(0)
max = 0

row, up = n-b, n
while row <= up:
    mid = (row+up)//2
    if n//b <= mid//b:
        up = mid-1
    elif n//b > mid//b:
        row = mid+1
print(int(a*(row)/b)-a*int((row)/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def val(a, b, x):
	return int((a * x) / b) - a * int(x / b)

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

def main(a, b, n):
		return max(val(a, b, n), val(a, b, (n // b) * b - 1), val(a, b, n - 1))

# n = 100
# for a in range(1, 100):
# 	for b in range(1, 1000):
# 		if naive(a, b, n) != main(a, b, n):
# 			print(a, b, naive(a, b, n), main(a, b, n))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def floor(x):
    return int(x)

if b<=n:
    print(a-1)
else:
    ans=floor(a*n/b)-a*floor(n/b)
    print(int(ans))

Submission status: Wrong Answer

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 >= 300:
    for i in range(N-300,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: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = a*n//b - a*(n//b)
print(ans)
for i in range(n, int(math.sqrt(n)), -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: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
'''
if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n%b)
else:
    maxT = 0
    i = n
    while i >= n-100:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    print(maxT)
'''
maxT = 0
i = n
while i >= n-500 and i >= 0:
    t = math.floor(a*i/b)-a*math.floor(i/b)
    if t > maxT:
        maxT = t
    i -= 1
print(maxT)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
if B>=N:
    for i in range(0,10**6):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)
elif B<N:
    for i in range(0,10**6):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    for i in range(0,10**6):
        x=B-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)

Submission status: Wrong Answer

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

ans = 0
count = 0
for x in range(N,0,-1):
    xb = x / B
    floor = int(A*xb) - A * int(xb)
    if ans <= floor:
        count = 0
        ans = floor
    elif count > 100000:
        break
    count += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
x=0
C=[]
while math.floor(x/B)==0:
  s=math.floor(A*x/B)-A*math.floor(x/B)
  C.append(s)
  x+=1
print(max(C))

Submission status: Wrong Answer

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 == 300000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
A,B,N = 5,7,4
max = 0
A_ = 0
for i in range(1,N+1):
  if i > 1 and int((A*i) % B) < int((A*i-1) % B):
    continue
  num = int((A * i)/B) - A * int(i/B)
  if num > max:
    max = num
    
    
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(x):
    return int(a*x/b)-a*int(x/b)


a,b,n=map(int,input().split())
left,right=0,n
while right>left+1:
    mid=(left+right)//2
    if f(right)>f(mid):
        left=mid
    else:
        right=mid
print(max(f(right),f(left)))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
Max = 0
e = 1/b
ae = a*e
axb = 0
xb = 0
temp = 0
h_cut = 0
u_cut = 0
for i in range(n):
  axb += ae
  xb += e
  h_cut = axb-int(axb)
  u_cut = (xb-int(xb))*a
  temp = u_cut-h_cut
  Max = max(Max, temp)
else:
  print(Max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n >= b:
  ans = (a*b)//b - a*(b//b)
  print(ans)
  quit()

ans = (a*n)//b - a*(n//b)

print(ans)

Submission status: Wrong Answer

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

if N > B:
    print(A * (B-1) // B)
else:
    print(A * N // B)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
if n>=b:
        
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*(b-1)/b)-a*int((b-1)/b)
    ans3=int(a*n/b)-a*int(n/b)
    print(max(ans,ans2,ans3))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print(max(ans,0))

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map( int, input().split() )
 
min_num = 1
max_num = N
 
def func( x ):
  return math.floor( A * x / B ) - A * math.floor( x / B )
  
ret = 0
while True:
  a = math.ceil( ( max_num + min_num ) / 2 )
  if func( min_num ) - func( max_num ) <= 0:
    min_num = a
  else:
    max_num = a
  if func( max_num ) == func( min_num ):
    break
 
print( func( a ))

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
if n <= b-1:
    print(math.floor(a*n/b))
else:
    print(math.floor(a*(n-1)/b))

Submission status: Wrong Answer

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

if N <B:
	print(int(math.floor(A*N/B)))
	exit()
    
if N%B==0:
	print(0)
	exit()

nagasa = int(math.floor(N/B))+1

k = [1]*nagasa

for i in range (0, nagasa):
	k[i] = (i+1)*B-1

k[-1] = N
    
boom=0

for i in range (0, nagasa):
	p = int(math.floor(A*k[i]/B)-A*math.floor(k[i]/B))
	if p> boom:
		boom = p

print(boom)