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

max_s = []
j = 0
if n > 10**6:
    print(int((a*n)/b) - a*int(n/b))
else:
    for i in range(n,0,-1):
        j += 1
        if j == int(10**6):
            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:
a, b, n = map(int, input().split())

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))
while True:
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    

# ans = max(buf)
print(buf[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    print(math.floor(A*N/B))
else:
    if N % B == 0:
        x = N-1
        print(math.floor(A*x/B) - math.floor(x/B)*A)
    else:
        p = N // B
        x = p*B - 1
        print(max(math.floor(A*x/B) - math.floor(x/B)*A, math.floor(A*N/B) - math.floor(N/B)*A))

Submission status: Wrong Answer

Solution code:
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,N = LMIIS()

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

    # ans2 = 0
    # for i in range(1,N+1):
    #     ans2 = max(ans2,floor(A*i/B)-A*floor(i/B))
    # print(ans2)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# A, B, N = map(int, input().split())
A, B, N = 5, 7, 4

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


def calculate(a, b, n):
    if N <= b:
        return a * n // b
    if N > b:
        if n >= 2 * b:
            x = b + b - 1
        else:
            x = n
        return (a * x) // b + a * (x // b)


print(calculate(A, B, N))

Submission status: Wrong Answer

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

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

    B_ans = 0
    for j in range(min(N, B), 1, -B):
        tmp = (A * j // B) - A * (j // B)
        B_ans = max(tmp, B_ans)
    
    print(max(B_ans, A_ans))

Submission status: Wrong Answer

Solution code:

def main():
    A, B, N = map(int, input().split())
    ans = 0
    if N > 10**8:
        print((A*(10**8))//B - A * ((10**8)//B))
    else:
        for i in range(1, N):
            ans = max(ans, (A*i)//B - A * (i//B))
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
a, b, n = map(int, input().split())
d = deque(list(math.floor(a*i/b)- a * math.floor(i/b) for i in range(1, min(n+1, 10000))))
print(max(d))

Submission status: Wrong Answer

Solution code:
import math

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

b=0
if B//N>1:
  b=N-1
else:
  b=B-B%N

c=math.floor(A*b/B)-A*math.floor(b/B)
print(c)

Submission status: Wrong Answer

Solution code:

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

if n > b:
    n_ = n // b
    x_ = n_ * b - 1
else:
    x_ = n

print(floor(a*x_/b) - a * floor(x_/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 = 6000000
	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 = 6000000
	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())

aaa = math.floor(A * N / B) - A * math.floor(N / B)

v = N % B
v += 1
bbb = 0
if N - v >= 0:
    bbb = math.floor(A * (N - v) / B) - A * math.floor((N - v)/ B)
ccc = 0
if B - 1 >= 0:
    ccc = math.floor(A * min((B - 1), N) / B)

Submission status: Wrong Answer

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=1e-10, max_loop=100):
    #初期値を表示
    num_calc = 0  #計算回数
    print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = (x_max +x_min)/2.0
        
        x_mid_max = (x_max +x_mid)/2.0
        x_mid_mim = (x_min +x_mid)/2.0
        
        #探索区間を更新
        if func_f(A,B,x_max) < func_f(A,B,x_mid):
            x_min = x_mid
        elif func_f(A,B,x_min) < func_f(A,B,x_mid):
            x_max = x_mid
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
        print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    solution = bisection(func_f, 0, N,A,B)
    print(-func_f(A,B,solution))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N

ans1 = (A * x//B) - A * (x // B)
ans2 = ((A * N)//B) - A * (N // B)
# print(ans2)
# ans = max(A-1, ans2)

if N < B:
    print(ans2)
else:
    print(A-1)

# exit()
exit()


# exit()
memo = [0] * (B+1)
ma = 0
for x in range(1, B+1):
    memo[x] = int((A * (x)/B)) - A * ((x)  // B)
    ma = max(memo[x], ma)
# print(memo[N-1])
print(memo)
# print(N)

# exit()
if N >= B:
    ans = ma
else:
    ans = memo[N]
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
a,b,n = map(int,input().split())
if a == 1:
    print(0)
    exit()

maxiidx = n
for i in range(n, 0, -1):
    if (i+1) % b == 0:
        maxiidx = i
        break

maxi = floor(a*maxiidx/b) - a*floor(maxiidx/b)
val = floor(a*n/b) - a*floor(n/b)
print(max(maxi,val))

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
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)
        break
    elif mae == 0 or ato == 0:
        result = C(x)
        break

print(max(C(low),C(high),result))

Submission status: Wrong Answer

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

for x in range(N+1):
    ans = math.floor(x * A // B) - A * math.floor(x//B)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
inp=[int(x) for x in input().split()]
a,b,n=inp[0],inp[1],inp[2]
print(min(math.floor(a*(b-1)/b)-b*math.floor((b-1)/b),n))

Submission status: Wrong Answer

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

if (b != 0):
  if (n >=b):
    x=math.floor(n/b)*b-1
    print (math.floor(a*x/b)-a*math.floor(x/b))
  else:
    print (math.floor(a*n/b)-a*math.floor(n/b))
else:
  print (0)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N <= 5000000:
    for x in range(1, N+1):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)
else:
    for x in range(1, 600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = N//2-300000
    for x in range(base, base+600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = A//2
    for x in range(base, A+600000):
        if x > N:
            break
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = B//2
    for x in range(base, B+600000):
        if x > N:
            break
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    for x in range(N-600000, N+1):
        tmp = math.floor((A*x/B))-A*(x//B)
        ans = max(ans, tmp)
print(int(ans))

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)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
    ans1 = ans
    ans2 = 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))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
maxi = min(A,N)
ans = 0
for i in range(1,maxi+1):
    ans = max(ans,math.floor((A*i)/7)-A*math.floor(i/7))
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import floor 
a,b,n=map(int,input().split())
ans=0
for x in range(n,n-3,-1):
    an=(floor(a*x/b))-a*floor(x/b)
    if an>ans:
        ans=an
print()
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
if n<b:
  print(int(a*n/b))
  exit()
if n<2*b:
  t = int(a*n/b)
  s = int(a*(b-1)/b)
  print(max(t,s))
else:
  t = int(a*(b-1))/b- int(a*(b-1)/b)
  s = int(a*(b+1))/b- int(a*(b+1)/b)
  q = int(a*(n))/b- int(a*(n)/b)
  print(max(t,s,q))

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+1:
    break

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
Smx = 0
if B<N:
    N = B
i = N
S = int((A*(i % B) - ((A*i) % B))/B)
print(S)

Submission status: Wrong Answer

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

def binary_search():
    low = 1
    high = n

    m = 0

    while low <= high:
        mid = (low + high) // 2

        l = int(a*low/b) - a * (int(low/b))
        h = int(a*high/b) - a * (int(high/b))

        m = max(m, h, l)

        if m == h:
            high = mid - 1
        elif m == l:
            low = mid + 1
            m = max(m, l)
        else:
            return m

    return m


print(binary_search())

Submission status: Wrong Answer

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

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

x = N if N < B else B
print(f(A, B, x))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
max = 0
i=N
while(1):
 cal = int((A*i)/B) - A*int(i/B)
 if(cal > max):
  max =cal
 i += -2
 if(i < 0):
  print(max)
  break;

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
A,B,N = map(int,input().split())
m = 0
for i in range(2000000):
    if N-i <= 0:
        break
    ans = math.floor((A*(N-i))/B)-A*math.floor((N-i)/B)
    if ans > m:
        m = ans
print(m)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
if x2 < 0:
    x2 =0
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)

print(max(f(x1), f(x2), f(0), f(1), f(N-1)))

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))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        ans3=int(a*(b-1)/b)-a*int((b-1)/b)
        ans4=int(a*(b+1)/b)-a*int((b+1)/b)
        ans5=int(a*(2*b-1)/b)-a*int((2*b-1)/b)
        ans6=int(a*(2*b+1)/b)-a*int((2*b+1)/b)
        p=n//b
        ans7=int(a*(p*b-1)/b)-a*int((p*b-1)/b)
        ans8=int(a*(p*b+1)/b)-a*int((p*b+1)/b)
        print(max(ans,ans2,ans3,ans4,ans5,ans6,ans7,ans8))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

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

Submission status: Wrong Answer

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

k = gcd(A, B)

As = A // k
Bs = B // k

if B < 100:
    res = []
    for n in range(min(N+1, B+1)):
        res.append(round(floor(As*n/Bs)-A*floor(n/B)))

    print(max(res))
    exit()

if Bs-1 <= N:
    m = Bs - 1
else:
    m = N
print(round(floor(As * m / Bs) - As * floor(m / Bs)))

Submission status: Wrong Answer

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

nibu_max = n
nibu_min = 1
nibu_mid = (1 + n) // 2


for i in range(int(math.log(n, 2)) + 1):
    sss_max = int(a * nibu_max / b) - a * int(nibu_max / b)
    sss_mid = int(a * nibu_mid / b) - a * int(nibu_mid / b)
    sss_min = int(a * nibu_min / b) - a * int(nibu_min / b)

    if sss_max > sss_mid:
        nibu_min = nibu_mid + 1
        nibu_mid = int((nibu_max + nibu_min) / 2)
    elif sss_mid < sss_min:
        nibu_max = nibu_mid - 1
        nibu_mid = int((nibu_max + nibu_min) / 2)
print(int(a * nibu_mid / b) - a * int(nibu_mid / b))

Submission status: Wrong Answer

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

ans = -1
if(a % b == 0):
    x = b-1
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc
else:
    for x in range(n-int(n**(1/2)),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Wrong Answer

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

lo = 1
hi = N

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

ans = 0
if B-1<=N:
    ans = f(B-1)

while hi > lo :
    if f(lo) <= f(hi):
        mid = (lo + hi) // 2
        if f(mid)<=f(mid+1):
            lo = mid+1
        else:
            lo = mid
    else:
        mid = -(-(lo + hi) // 2)
        hi = mid

ans = max(ans,f(lo),f(N-1),f(B*N//B-1),f(B-1))-1

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
#"""
if N < B:
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*(N-1)/B)-A*floor((N-1)/B)))
else:
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*B/B)-A*floor(B/B),floor(A*(B-1)/B)-A*floor((B-1)/B)))
#"""

Submission status: Wrong Answer

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

if B<N:
    print(N)
else:
    list=(math.floor((A*N)/B)-A*(math.floor(N/B)))
    print(list)

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=1000000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))
if n%2==0:
    nmid=int(n/2)
if n%2==1:
    nmid=int(n+1/2)
for i in range(nmid):
    if i>teisuu:
        break
    temp=nmid-i
    maxtemp=max(maxtemp,funcsum(temp))

for i in range(nmid):
    if i>teisuu:
        break
    temp=nmid+i
    maxtemp=max(maxtemp,funcsum(temp))
print(maxtemp)

#items=[int(i) for i in input().split()]


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

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

if a <= b:
    if a >= n:
        #n_tmp = n % a
        #print(n_tmp)
        #if n_tmp == 0:
        n_tmp = n
        ans = int(a*n_tmp/b) - a*int(n_tmp/b)
        print(ans)
        #print('####')

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

    else:
        ans = a-1
        print(ans)

else:
    if a >= n:
        ans_max = 0
        n_tmp = n
        for x in range(n_tmp+1):
            ans = int(a*x/b) - a*int(x/b)
            #print(ans)
            if ans_max < ans:
                ans_max = ans

        print(ans_max)

    else:
        ans_max = 0
        n_tmp = a % n
        for x in range(n_tmp + 1):
            ans = int(a * x / b) - a * int(x / b)
            #print(ans)
            if ans_max < ans:
                ans_max = ans

        #print('max##########################')
        print(ans_max)

        #print('############################################################')
        #for x in range(n + 1):
        #    ans = int(a * x / b) - a * int(x / b)
        #    print(ans)
            #if ans_max < ans:
            #    ans_max = ans

        #print(ans_max)

Submission status: Wrong Answer

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

def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)

ans = function(1)
for i in range(1, max(1, (n + 1) // b)):
    ans = max(ans, function(i * b - 1))

print(max(ans , function(n)))

Submission status: Wrong Answer

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

if B > N:
    ans = int(A*N/B)
    print(ans)
else:
    # t = int(A*N/B)- A*int(N/B)
    t = 0
    ans = 0
    x = (N//B)*B - 1
    temp = int(A*x/B) - A*int(x/B)
    while ans <= temp and x >= 0:
        ans = temp
        temp = int(A*x/B) - A*int(x/B)
        x -= B
    print(max(ans, t))

Submission status: Wrong Answer

Solution code:
import math


A,B,N = map(int, input().split())
fi = math.floor(((B-N)*A)/B)
sec = math.floor((B-N)/B)
print(fi-A*sec)

Submission status: Wrong Answer

Solution code:
func = []
A , B , N = map(int , input().split())
"""
for x in range(N+1):
    func.append((A*x) // B  - A * (x // B ))
#print(max(func))
"""
print((A*(B-1)) // B  - A * ((B-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 = 6000000
	for x in range(N,A,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 6000000
	for x in range(A,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())
if N < B:
  print(int(A * N / B))
else:
  print(int(A * (N % B) / B))

Submission status: Wrong Answer

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

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


'''

for i in list1:

    if lv[i[1]-1]-lv[i[0]-1]==i[2]:
        #print(lv)
        #print(i)
        sum1+=i[3]


if max<=sum1:
    max=sum1




print(max)
'''