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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 10000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 12000000
	for x in range(B,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

if c1 < c2:
    for i in (range(n+1)):
        c = math.floor(a*i/b)-a*math.floor(i/b)
        if m < c:
            m = c
            print(i)
        else:break
else:
    for i in reversed(range(n+1)):
        c = math.floor(a*i/b)-a*math.floor(i/b)
        if m < c:
            m = c
        else:break
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
kind=set()
bef=-100
for i in range(1,n+1):
    num=calc(i)
    if num in kind:
        if bef==num:
            break
    kind.add(num)
    bef=num
print(max(kind))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for x in range(0,N):
  c = decimal.Decimal(str(A*x/B))
  C = int(c.quantize(decimal.Decimal('0'), rounding=decimal.ROUND_FLOOR))
  d = decimal.Decimal(str(A*x/B))
  D = int(d.quantize(decimal.Decimal('0'), rounding=decimal.ROUND_FLOOR))
  D = D * A
  E = D-C
  S.append(E)
  
print(S.index(max(S)))

Submission status: Wrong Answer

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

import math

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

box.sort(reverse=True)
print(box[0])
#print(box)

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(n):
    x = x+1
    si = math.floor(a*x/b)-x*math.floor(x/b)
    if (s < si):
        s = si
        i = x
    # print("x s si i")
    # print(x, s, si, i)

print(i)

Submission status: Wrong Answer

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

ans = 0
i = 1
while True:
    i += max(1, B//A)
    if i > N:
        break
    tmp = ((A*i)//B) - (A*(i//B))
    if tmp > ans:
        ans = tmp
    else:
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
def func(i, j, k):
    return (i*k)//j
m = min(n, b)
r = (a*min(n, b)) // b
while ((a*m) // b) == r:
    print(m)
    m -= 1
print(func(a, b, m+1))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
x = 0
loop1 = n//b + 2
if loop1 > 10**5:
    loop1 = 10**5
    
loop2 = n//a + 2
if loop2 > 10**5:
    loop2 = 10**5

max_ = 0
    
if n < 10**5:
    for x in range(1, n + 1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

else:
    for x in range(1, 10**4):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
            
    for i in range(1, loop1):
        x = i*b - 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

    for i in range(1,loop2):
        x = i*a + 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        print((a*x)//b,a*(x//b), tmp)
        if tmp > max_:
            max_ = tmp
    
print(max_)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
 
A, B, N = map(int, input().split())
c = 0
for x in range(N, 1, -1):
    j = (A*x / B)
    k = (x / B)
    if j < 1 and k < 1:
        pass
    else:
        a = math.floor(j) - A * math.floor(k)
        if a <= c :
            break
        c = a
print(c)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    xans=N-(N%B)-1
    if xans>N:xans=N
    print(f(A,B,xans))
#%%submit!
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B:
    n = N//B
    n = n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
else:
    ans1 = ans
    ans2 = ans
    ans3 = ans
    ans4 = ans
if N > 100000:
    p = N-100000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(max(ans, ans1, ans2, ans3, ans4))

Submission status: Wrong Answer

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

y = min(b, n)

print((a*y)//b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

import math


if __name__ == '__main__':
    a, b, n = map(int, input().split())

    m = 0
    for x in range(n):
        m = max(m, math.floor(a * x / b) - a * math.floor(x / b))
    print(m) # debug

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A, B , N=  [int(i) for i in input().split()]

#if A > B:

N  = int(int(A*N/B) * B /A)
print(int(A*N/B) - A*int(N/B))

#else:

Submission status: Wrong Answer

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

if b >= n:
    ans = math.floor(a*n/b) - a * math.floor(n/b)
    ans = max(ans, math.floor(a*(n-1)/b) - a * math.floor((n-1)/b))

else:
    ans = 0
    r = min(n-b, b)
    for i in range(r + 1):
        x = n - i
        v1 = math.floor(a*x/b)
        v2= a * math.floor(x/b)
        v =  v1 - v2
        #print(x, a, x/b, v1, v2, v)
        ans = max(ans,v)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def func(i):
    return math.floor(a * i * 1.0 / b) - a * math.floor(i * 1.0 / b);
 
a, b, n = map(int, input().split())
 
print (max(func(b), func(n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
abn = list(map(int, input().split()))
a = abn[0]
b = abn[1]
n = abn[2]
ans = -100000000000000000000000000
for x in range(n + 1):
  val: int = math.floor(a * x / b) - a * math.floor(x / b)
  if val > ans:
    ans = val
print(val)

Submission status: Wrong Answer

Solution code:
import math

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

t=0
if B==1:
    print(0)
else:
    if B >= N:
        print(math.floor(A*N/B))
    else:
        for x in range(B+1,N+1):
            y=math.floor(A*(B-1)/B)
            if math.floor(A*x/B)-A*math.floor(x/B) > y:
                y= math.floor(A*x/B)-A*math.floor(x/B)
            

        print(y)

Submission status: Wrong Answer

Solution code:
def f1(a, b, x):
  return int(a * x / b)
 
def f2(a, b, x):
  return a * f1(1, b, x)
 
a, b, n = map(int, input().split())
result = 0
 
result = f1(a, b, n)-f2(a, b, n)
    
 
print(result)

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin
input = stdin.readline
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  sTgt_past=0
  if(N//B>=1):
    print(A-1)
  else:
    sMin=min(N,B)
    for i in range(1,sMin+1):
      sTgt=int(A*i/B)-A*int(i/B)
      if(i==1):
        sMax=sTgt
      else:
        sMax=max(sMax,sTgt)
      sTgt_past=sMax
    print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Wrong Answer

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

if a % b == 0:
  ans = n
else:
  if n % b == 0:
    x = n - 1
  else:
    x = n
  ans = (a * x) // b - a * (x // b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
 
A, B, N = map(int, input().split())
c = 0
for x in range(N, 1, -1):
    j = (A*x / B)
    k = (x / B)
    if j < 1 and k < 1:
        pass
    else:
        a = math.floor(j) - A * math.floor(k)
        if a <= c :
            break
        print(x, a)
        c = a
print(c)

Submission status: Wrong Answer

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


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

    x = (n // b) * b - 1
    if x < 0:
        x = n
    # r = max(int(a * x / b) - a * (x // b),
    #         int(a * n / b) - a * (n // b))
    r = max(int(a * i / b) - a * (i // b) for i in range(x, n + 1))
    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(int(n), int(n-30), -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Wrong Answer

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

print(math.floor((A*N)/B) - (A*math.floor(N/B)))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    m = a-1
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        if c >= m:
            m=c
        else:
            break
print(m)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
ans = -100000000000
pre = 10**9
ans = 0

for i in range(min(A,B,N+1)):
    t = (A*i) // B - A * (i//B)
    if pre < ans :
        break
    if ans < t:
        ans = t
    pre = t
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans = 0
x = 0
t = ((A * x) // B) - (A * (x // B))
while x >= 0:
    x += 1
    t2 = ((A * x) // B) - (A * (x // B))
    if t2 < t:
        ans = t
        break
    t = t2

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = (int(i) for i in input().split())
for i in range(N):
    x = N
    if x // B < 1:
        c = int((A*x)/B) - (A*int(x/B))
        print(c)
        break
    else:
        N -= B

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
cnt = 0
siki = 0
if B < N :
    for i in range(B) :
        siki = floor(A*i/B) - A * floor(i/B)
        cnt = max(siki,cnt)
else :
    cnt = floor(A*N/B) - A*floor(N/B)

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def main():
    a, b, n = map(int, input().split())
    if b > n:
        ans = (a * n) // b
    elif b == n:
        ans = (a * (n - 1)) // b
    else:
        ans = (a * b) // b
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

    if b < n:
        for x in range(b-1, n+1, b):
            yd = (x/b)-floor(x/b)
            if yd > mx:
                mx = yd
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 10000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 11190000
	for x in range(0,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def F(x):
    return (a*x//b)-a*(x//b)

l=0
r=n+1
ans1=0

for i in range(60):
    m=(r+l)//2
    f=F(m)
    #print(m,f,ans)
    if f>ans1:
        ans1=f
        l=m
    else:
        r=m
    
#print(ans1)
#print(F(500))



ans2=0
if n<=10**6:
    for i in range(n+1):
        f=F(i)
        if f>ans2:
            ans2=f
        #print(i,ans)
#print(ans2)
    print(ans2)
else:
    print(ans1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    print(max)

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 - left) // 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 sys

input = sys.stdin.readline
MOD = 1000000007

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


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

res = 0
left = 0
right = N

left_res = 0
right_res = 0

while (left+1) != right:
    left_res = f(left)
    right_res = f(right)
    mid = (right+left)//2
    if left_res > right_res:
        right = mid
    else:
        left = mid

print(max(f(left),f(right)))

Submission status: Wrong Answer

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

if B == 1:
    ans = 0
elif B == N:
    ans = A - 1
elif B < N:
    ans = (A - 1)//2
else:#B > N
    ans = int(N*A/B)-A*int(N/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())
li = []
for x in range(n-2, n+1):
    an = math.floor(a*x//b) - a * math.floor(x//b)
    li.append(an)
print(max(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

if b == 1:
  ans = 0

else:
  for x in range(0, a * n, b):
    new = math.floor(x / b) - a * math.floor((x / a) / b)
    if new > ans:
      ans = new

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(int(n), int(n-20), -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def C(x):
    return math.floor(A*x / B) - A*math.floor(x/B)

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

high = N
low = 1
x = N//2
result = 1
count =0
while low < high:

    mae = C(x) - C(x-1)
    ato = C(x+1) -C(x)
    if mae > 0 and ato > 0:#単調増加
        low = x +1
        x = (high + low)//2
    elif mae < 0 and ato < 0:#単調減少
        high = x -1
        x = (high + low)//2
    elif mae> 0 and ato < 0:
        result = C(x)
        count = 1
        break
    elif mae == 0 or ato == 0:
        result = C(x)
        count = 1
        break
if count == 1:
    print(max(C(low),C(high),result))
else:
    print(max(C(low),C(high)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
import math
 
def has_duplicates(seq):
    return len(seq) != len(set(seq))
 
A,B,N = map(int, input().split())
List=[]
i=1
while i<=N:
    one=math.floor((A*i)/B)
    two=math.floor(i/B)
    three=A*two
    ans=one-three
    List.append(ans)
    #print(ans)
    if ans==List[0] and i>1:
        break
    i+=1
#print("ans")
print(max(List))