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: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

Solution code:
A,B,N= list(map(int, input().split()))
print(int(A*min(B-1,N)/B)-A*int(min(B-1,N)/B))

Submission status: Accepted

Solution code:
a,b,n=map(int, input().split())
cand1=(a*n)//b-a*(n//b)
x=n-n%b-1
cand2=0
if x>=0:
    cand2=(a*x)//b-a*(x//b)
cand1=max(cand2,cand1)
print(cand1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
a,b,n = MI()
if n >= b:
  n = b-1
  print(math.floor(a*n/b)-a*math.floor(n/b))
else:
  print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor, gcd

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

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    # mods = []
    
    a = f(min(B-1, N), A, B)
    print(a)
    
    
main()

Submission status: Accepted

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
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

if n <= (b-1):
    print(calc(n))
else:
    print(calc(b-1))

Submission status: Accepted

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

p=min(N,B-1)
ans =math.floor(A*p/B)-A*math.floor(p/B)

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    A, B, N = map(int, input().split())
    print(A * min(N, B - 1) // B)


resolve()

Submission status: Accepted

Solution code:
import numpy as np
if __name__ == "__main__":
    # 入力パターン．
    # 要素の数がわかっているパターン
    ### a b
    A, B, N = map(int, input().split())

    x = min(B-1, N)
    ans = int(A*x/B) - A * int(x/B)
        
    print(ans)

Submission status: Accepted

Solution code:

A, B, N = map(int, input().split())
# xはN以下
# int(A*x/B) - A*int(x/B)の最大値を求めたい


# print(compute_range)


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


max_num = h(min(B - 1, N))
print(max_num)

Submission status: Accepted

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
  Ymax = A*x//B - A*(x//B)
  print(Ymax)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b, n = list(map(int, input().split()))
max_value = 0
trial = n

x = min(b-1, n)
ans = x*a//b
ans -= a*(x//b)
print(ans)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    # for i in range(n, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    # if n // b * b - 1 >= 0:
    # if b <= n:
    #     n = n // b * b - 1
    # 
    # if (a * n) % b == 0:
    #     n -= 1

    n = min(b - 1, n)

    ans = math.floor((a * n) / b) - a * math.floor(n / b)

    # print('ans')
    # print(n, ans)
    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

ans = 0
if B != 1:
    if N < B:
        ans = int(A*N/B) - A * int(N/B)
    else:
        x = N//B * B - 1
        ans = int(A*x/B) - A * int(x/B)

print(ans)

Submission status: Accepted

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


def calc(x):
    return (A*x)//B - A*(x//B)

print(calc(min(B-1, N)))

Submission status: Accepted

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

Submission status: Accepted

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

print(f(min(B-1,N)))

Submission status: Accepted

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


num = list(map(int, input().split()))
a = num[0]
b = num[1]
n = num[2]
x = (int(n/b) + 1) * b - 1
max_num = f(a, b, min(b-1, n))
print(max_num)

Submission status: Accepted

Solution code:
#!python3

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


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


def main():
    ans = f(min(B - 1, N))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

m = b/a
if b <= n:
    print(math.floor(a*(b-1)/b) - a*math.floor((b-1)/b))
else:
    print(math.floor(a*n/b) - a*math.floor(n/b))

Submission status: Accepted

Solution code:
import math


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

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

    print(target(min(N, B-1)))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

if n<b:
    print(F(n))
elif n==b:
    print(F(n-1))
else:
    print(F(b-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
import collections
# X = int(input())
A, B, N = map(int, input().split())
if B-1 < N:
	print(int(A*(B-1)/B))
else:
	print(int(A*N/B))

Submission status: Accepted

Solution code:
import math

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

if N < B:
    x = N
else:
    x = B - 1

def check(x):
    return math.floor((A * x) / B)
            
print(check(x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor

a,b,n = map(int, input().split())
i = min(n,b-1)
print(floor(a*i/b) - a*floor(i/b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
A,B,N = map(int,input().split())
max = 0
m = []
def f(x):
  return math.floor(A*x/B) - A*math.floor(x/B)

if N < B:
  max = f(N)
elif N == B:
  max = f(N-1)
else:
  max = f(B-1)
print(max)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
from bisect import bisect_left

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

def solve(A: int, B: int, N: int):
    def func(x):
        return math.floor(A/B * (x%B))

    leftmost = 1
    rightmost = min(N,B)
    midpoint = rightmost // 2
    
    midpoint = min(N,B-1)
    ans = math.floor(A*midpoint/B) - A*math.floor(midpoint/B)
    print(ans)

    # i = 0
    # over_N =0
    # while over_N < N:
    #     x = 10 * 10**i
    #     over_N = func(A, B, x)
    #     i += 1

    # while True:
    #     out = func(A, B, x)
    #     if  out <= N:
    #         break
    #     else:
    #         x -= 1

    # print(func(A, B, x))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, n = [int(i) for i in input().split()]
m = b - 1 if n >= b else n

print((a * m // b) - a * (m // b))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

temp_prev = 0
temp_curr = 0
x = min(n, b-1)

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr <= temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Accepted

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

def main():
    A, B, N = map(int, input().split())
    ans = -1
    for x in range(min(B-1, N), max(min(B-1, N)-N, -1), min(-B+1, -1)):
        ans = max(ans, f(x, A, B))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if b == 1:
    r = [0]
else:
    i = 0
    r = [int((a*n)/b)-a*int(n/b)]
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
        i += 1
print(max(r))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, N = list(map(int,input().split()))
MAX = float('inf')*(-1)
a = int(A/B)
b = B
if N < B:
    MAX = (A * N // B) - A * (N // B)
else:
    MAX = (A * (B-1) // B) - A * ((B-1) // B)
print(MAX)

Submission status: Accepted

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  x=N
  s=(A*x)//B - A*(x//B)
print(s)

Submission status: Accepted

Solution code:
import math
A,B,N = map(int,input().split())
max = 0
m = []
def f(x):
  return math.floor(A*x/B) - A*math.floor(x/B)

if N < B:
  max = f(N)
elif N == B:
  max = f(N-1)
else:
  max = f(B-1)
print(max)

Submission status: Accepted

Solution code:
import math

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

b=0

if N>=B:
  b=B-1
else:
  b=N

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

Submission status: Accepted

Solution code:
import math

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

c = 0
ans = 0
for i in range(1,10**7) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    ans = max(ans,math.floor((a*x)/b)-a*math.floor(x/b))
    if c == 1 :
        break

print(ans)

Submission status: Accepted

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

A, B, N = MAP()

left, right = 0, N

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


# while right-left > 1:
#     mid1 = (left + right)*1// 3
#     mid2 = (left + right)*2// 3

#     if f(mid1) < f(mid2):
#         if left == mid1:
#             break
#         left = mid1
#     else:
#         if right == mid1:
#             break
#         right = mid2

# ans = f(left)
# for i in range(left, right+1):
#     ans = max(ans, f(i))
# print(ans)
# ans = 0
# # whilefor i in range(1, N+1):
# #     ans = max(ans, f(i))
# # print(ans)

# x = N//2
# if f(x) <= f(x)
# direc = "R"

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 22:26:54 2020

@author: Kanaru Sato
"""

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

def floorspecial(x):
    u = (a*x)//b
    v = a*(x//b)
    print(int(u-v))

if a == 1:
    print(0)
elif n < b:
    floorspecial(n)
else:
    p = (n//b)*b
    p = p-1
    floorspecial(p)

Submission status: Accepted

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

Submission status: Accepted

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

def floor(t):
  return int(t)

Ans = floor(A * min(N, B-1) / B)
  
print(Ans)

Submission status: Accepted

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 * (B-1)//B) - A * ((B-1) // B)
ans2 = ((A * N)//B) - A * (N // B)
# print(ans2)
# ans = max(A-1, ans2)

if N < B:
    print(ans2)
else:
    
    print(ans1)

# 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: Accepted

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

def floor(m):
    return int(m)

if n>=b:
    x=b-1
    c= floor(a*x/b) - a*floor(x/b)
else:
    x=n
    c= floor(a*x/b) - a*floor(x/b)

print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

if B <= N:
    max = math.floor(A * (B - 1) / B) - (A * math.floor((B - 1) / B))
else:
    # for i in range(1, N + 1):
    #     temp = math.floor(A*i/B) - (A * math.floor(i/B))
    #     print(str(i) + ' ' + str(temp))
    #     if bk_temp > temp:
    #         max = bk_temp
    #         break
    #     if max < temp:
    #         max = temp
    #     bk_temp = temp
    max = math.floor(A * N / B) - (A * math.floor((N) / B))

print(max)

Submission status: Accepted

Solution code:

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

score = 0

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, N: int):
    def f(x):
        return A * x // B - A * (x // B)
    if B - 1 <= N:
        print(f(B - 1))
    else:
        print(f(N))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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
    if N >= B -1:
        print(floor(A*(B-1)/B)-A*floor((B-1)/B))
    else:
        print(floor(A*N/B)-A*floor(N/B))
    
    # 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: Accepted

Solution code:
from math import floor

a,b,n=map(int,input().split())
ans=0
x=b-1
if x>=n:
    x=n
ans = floor(a*x/b) - 5*floor(x/b)
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]

def a(A,B,x): return (A*x//B)-A*(x//B)

def main():
    A,B,N = MI()
    """
    max = 0
    m = 0
    for x in range(0, N+1):
        ai = a(A,B,x)
        if max < ai :
            max = ai
        elif ai<0 and m == 0:
            max = ai
            m +=1

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

    



    


if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
from math import floor

line = [int(ch) for ch in input().split()]
a = line[0]; b = line[1]; n = line[2]
if b <= n:
    x = b-1
else:
    x = n
res = floor(a*x/b) - a*floor(x/b)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if N < B:
    print((A*N)//B)
elif N == B:
    NN = N-1
    print((A*NN)//B)
else:
    
    wN = N % B
    wwN = B * wN -1
    sahen1 = (A*wwN)//B
    uhen1 = A * (wwN//B)
    kouho1 = sahen1 - uhen1

    sahen2 = (A*N)//B
    uhen2 = A * (N//B)
    kouho2 = sahen2 - uhen2
    print(max(kouho1,kouho2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, N = mapint_inp()

from math import floor

S_1 = (A*N)//B
S_2 = A*(N//B)
if N < B:
    print(S_1-S_2)
else:
    print(((A*(B-1))//B))

Submission status: Accepted

Solution code:
import math

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

m = 0
if n<b:
    m = math.floor(a*n/b)
else:
    m = math.floor(a*(b-1)/b)-a*math.floor((b-1)/b)
print(m)

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

Solution code:
A,B,N=map(int,input().split())
x=B-1
def f(t):
    return int(t//1)
if N>=B:
    M=f(A*x/B)-A*f(x/B)
    print (M)
else:
    N=f(A*N/B)-A*f(N/B)
    print (N)

Submission status: Accepted

Solution code:
import sys
import math
import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

# ===CODE===

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

left = 1
right = n

ans = 0
num = 0
while abs(left - right) > 10 ** (-2):
    tmp_left = left + (right - left) / 3
    tmp_right = left + 2 * (right - left) / 3

    c_left = math.floor(a * left / b) - a * math.floor(left / b)
    c_right = math.floor(a * right / b) - a * math.floor(right / b)

    f_left = math.floor(a * tmp_left / b) - a * math.floor(tmp_left / b)
    f_right = math.floor(a * tmp_right / b) - a * math.floor(tmp_right / b)

    if c_left <= f_left <= f_right:
        left = tmp_left
        if ans < f_left:
            ans = f_left
            num = tmp_left

    elif f_left >= f_right >= c_right:
        right = tmp_right
        if ans < f_right:
            ans = f_right
            num = tmp_right
    else:
        if c_left > c_right:
            right = tmp_right
            if ans < f_right:
                ans = f_right
                num = tmp_right
        else:
            left = tmp_left
            if ans < f_left:
                ans = f_left
                num = tmp_left

ans1 = math.floor(a * int(num) / b) - a * math.floor(int(num) / b)
ans2 = math.floor(a * int(num + 1) / b) - a * math.floor(int(num + 1) / b)

print(int(max(ans1, ans2)))

Submission status: Accepted

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

in_a = list(map(int, input().split()))
A = in_a[0]
B = in_a[1]
N = in_a[2]

ans = 0

if ( B>N ):
  X = N
  ans = math.floor(A*X/B) - ( A * math.floor(X/B) )
  
else:
  X = B - 1
  ans = math.floor(A*X/B) - ( A * math.floor(X/B) )

print(ans)

Submission status: Accepted

Solution code:
import math

params0 = list(map(lambda x: int(x), input().split(' ')))
paramA = params0[0]
paramB = params0[1]
paramN = params0[2]

a = 0
if paramN > paramB - 1:
    a = paramB - 1
else:
    a = paramN

print(math.floor(paramA * a / paramB) - (paramA * math.floor(a / paramB)))

Submission status: Accepted

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

mf=math.floor
if N<B-1:
    q=mf(A*N/B)-A*mf(N/B)
    print(q)
else:
    a=math.floor(A*(B-1)/B)
    print(a)

Submission status: Accepted

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

def calc(x):
    return floor((A*x)/B)-A*floor(x/B)
if B-1<=N:
    print(calc(B-1))
else:
    print(calc(N))

Submission status: Accepted

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

x = 0

if N >= B:
    x = B-1
else:
    x = N
    
print(math.floor((A*x)/B)-A*math.floor(x/B))

Submission status: Accepted

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

Submission status: Accepted

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

x = 0
if B <= N:
    x = B - 1
else:
    x = N

print(((A * x) // B) - (A * (x // B)))

Submission status: Accepted

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

Submission status: Accepted

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

# -- submit ----
import math

# --- fetch input ---
inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---
a, b, n = (int(i) for i in inputs[0].split())

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

Submission status: Accepted

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

prev = 0

for x in range(min(b-1,n),n+1, b):
    val = floor(a*x/b) - a*floor(x/b)
    if val < prev:
        print(prev)
        exit()
    prev = val

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

Submission status: Accepted

Solution code:
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)
a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    print(f(a, b-1, b))

Submission status: Accepted

Solution code:
import math


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

aaa = (math.floor(a * (b - 1) / b)) - (a * math.floor((b - 1) / b))

if n < (b - 1):
    aaa = (math.floor(a * n / b)) - (a * math.floor(n / b))

print(aaa)

Submission status: Accepted

Solution code:
N, M, K = map(int, input().split())
print(N*min(M-1, K)//M)

Submission status: Accepted

Solution code:
import math
from collections import deque
a,b,c=[int(_) for _ in input().split()]
if c>=b:
    k=b-1    
else:
    k=c
s=math.floor((k*a)/b)-a*math.floor(k/b)
print(s)

Submission status: Accepted

Solution code:
import numpy as np
import math

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

i = B-1

if i >= N:
  x = N
else:
  x = B-1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

max_v = 0

if N < B:
    max_v = calc(N)
else:
    max_v = calc(B-1)

# for x in range(N+1):
#     print(x,max_v) # x＝Bでさちる
#     max_v = max(max_v, calc(x))

print(max_v)

Submission status: Accepted

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

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

Submission status: Accepted

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

def func(A, B, N):
  if N>B-1:
    return math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
  else:
    return math.floor(A*N/B)-A*math.floor(N/B)


print(func(A,B,N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int, N: int):
    result1 = int(A*(B-1)/B) - A * int((B-1) / B)
    result2 = int(A*N/B) - A*int(N/B)
    if N <= B-1:
        print(min(result1, result2))
    else:
        print(result1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(max(0,m*(B-1)-1+j))
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B)))

Submission status: Accepted

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

Submission status: Accepted

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

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

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