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:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

import random


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

def main():
    A, B, N = MI()
    ans = 0
    s = set()

    x = B - 1
    # print(f(x, A, B))

    if x >= N:
        # print(x, N)
        x = N

    # print('x', x)
    print(f(x, A, B))
    # print(3, f(3, A, B))
    # print(4, f(4, A, B))

    # for x in range(min(N+1, 10**6)):
    #     d = f(x, A, B)
    #     ans = max(ans, d)
    #     s.add(d)
    #     print(x, d)

    # print(s)
    # print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(a: int, b: int, n: int) -> int:
    x = min(n, b - 1)
    return (a * x) // b - a * (x // b)


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    A, B, N = list(map(int, input().split()))
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = solve(A, B, N)
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split())
def val(x):
  global a, b, n
  return int((a*x)//b - a*(x//b))

if n >= b:
  print(val(b-1))
else:
  print(val(n))

Submission status: Accepted

Solution code:
###
# main
if(__name__ == '__main__'):
    # input
    a, b, n = map(int, input().split(" "))

    mod = n % b
    div = n // b

    x = n
    if div == 0:
        if mod == 0:
            x = n-1
    else:
        if mod == 0:
            x = n-1
        else:
            x = n-mod-1
    
    floor_ax_b = (a * x) // b
    floor_x_b = x // b

    ans = floor_ax_b - a * floor_x_b

    # output
    print(ans)
# else:
    # do nothing

Submission status: Accepted

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

max_d = min(B - 1, N)
max_r = max_d / B

res = int(max_r * A)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s1 = math.floor(a * n / b) - a * math.floor(n / b)
if n < b:
    print(s1)
    exit()

ans = 0
for i in range(b, b - 10*3, -1):
    ans = max(math.floor(a * (b-1) / b) - a * math.floor((b-1) / b), ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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



print(solve())

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq

MOD = 1000000007


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    A, B, N = get_inputs(int)
    if N >= B-1:
        print(math.floor(A - A/B))
    else:
        print(math.floor(A * N / B))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    a, b, n = map(int, input().split())
    r = 0
    if n >= b:
        r = b - 1
    else:
        r = n

    print(a * r // b)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
from math import floor

def main():
    a,b,n = (int(x) for x in input().split())
    if b <= n:
        ans = floor(a*(b-1)/b)
    else:
        ans = floor(a*(n)/b)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def f(a,b,x):
	return int(a*x/b) - a*int(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 = map(int,input().split())
if n >= b-1:
    print(a*(b-1)//b)
else:
    print(a*n//b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_ABN = input().split(' ')
A = int(input_ABN[0])
B = int(input_ABN[1])
N = int(input_ABN[2])

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

Submission status: Accepted

Solution code:
def solve():
    A,B,N = map(int,input().split())
    print(max(express(A,B,N), express(A,B,max(N//B*B-1,0))))

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
A,B,N = map(int,input().split())
score = 0
if N>=B:
    x = B-1
else:
    x = N

score = int(A*x/B)-A*int(x/B)
print(score)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
a,b,n = map(int,input().split())
xbmodlist = []
ans_list = []
if b == 1:
    print(0)
    
else:
    if n >= b-1:
        tmp = b-1
        if b!= 1:
            while tmp <= n:
                xbmodlist.append(tmp)
                tmp += b-1
            for i in xbmodlist:
                ans_list.append(np.floor(a*i/b)-a*np.floor(i/b))

            print(int(max(ans_list)))
    else:
        print(int(np.floor(a*n/b)-a*np.floor(n/b)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor


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


def solve(a, b, n):
    return f(a, b, min(b-1, n))


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

Submission status: Accepted

Solution code:
from math import floor
def seq(a, b, x):
    return int(floor((a*x)/b)) - int(a*floor(x/b))
ma = 0
a, b, n = map(int, input().split())
n = min(n, b)
low = 1
high = n
ans = 0
while low<=high:
    mid = low + (high-low)//2
    if seq(a, b, mid)>=seq(a, b, mid-1):
        low = mid+1
        ans = mid
    else:
        high = mid-1
print(seq(a, b, ans))

Submission status: Accepted

Solution code:
import math 


a, b, n = map(int, input().split())
if b > n:
    x = n    
else:
    x = b-1
print(math.floor(a*x/b)-a*math.floor(x/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:
import math
def main():
    a, b, n = map(int,input().split())
    x=b-1
    if x>n:
        x=n
    ans=math.floor(a*x/b)-a*math.floor(x/b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def factor(N):
    ans = []
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

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


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

Submission status: Accepted

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

x = min(B-1, N)

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

Submission status: Accepted

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)
else:
    num = b - 1
    ans = math.floor(a*num/b) - a*math.floor(num/b)
print(ans)

Submission status: Accepted

Solution code:

a,b,n=map(int,input().split())
i=(n//b)*b
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))

Submission status: Accepted

Solution code:
def main():

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

    def gcd(a, b):
        if a > b: a, b = b, a
        if a == 0: return b
        return gcd(b%a, a)

    g = gcd(A, B)
    p = A // g
    q = B // g
    # print(g, p, q)
    return int(p * min(N, B-1) // q)



if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor
a, b, n = [int(x) for x in input().split()]
def e(x):
	return floor(a * x // b) - a * floor(x // b)
candidates = [a, a - 1, b-1, b, n-1, n]
print(max(*[e(x) for x in candidates if x >= 1 and x <= n]))

Submission status: Accepted

Solution code:
from math import *
A,B,N=map(int,input().split())
i=min(B-1,N)
print(floor(A*i/B)-A*floor(i/B))

Submission status: Accepted

Solution code:
import numpy as np
nmq = input()
[a, b, n] = [int(comp) for comp in nmq.split()]


def func(x):
  global a, b
  return int(a * x // b) - a * int(x // b)


if(n < b):
  print(func(n))
else:
  print(func(b - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

A,B,N = map(int,input().split())
x = min(B-1,N)


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

Submission status: Accepted

Solution code:
import math
A, B, N = [int(x) for x in input().split()]
if B > N:
    x = N
else:
    x = B - 1
print(math.floor(A*x/B)-A*math.floor(x/B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

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

ans = func(min(B - 1, N))
print(ans)

Submission status: Accepted

Solution code:
import math
a,b,n = map(int,input().split())
if n >= b-1:
	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:
a, b, n = map(int, input().split())

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

Submission status: Accepted

Solution code:
A,B,N = map(int,input().split())
if N < (B-1):
  x = N
else:
  x = 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())
x=(N//B)*B-1
ans=(A*N)//B - A*(N//B)
if N>=B:
    ans=max(ans, (A*x)//B - A*(x//B))
print(ans)

Submission status: Accepted

Solution code:
import collections
import math
import itertools
import sys
sys.setrecursionlimit(10**6)
def f(x):
  return (a*x)//b - a*(x//b)
ma = lambda :map(int,input().split())
ni = lambda:int(input())
a,b,n = ma()
if n>=b-1:
    print(f(b-1))
else:
    print(f(n))

Submission status: Accepted

Solution code:
str1 = str(input(' '))
l = str1.split(' ')
a = int(l[0])
b = int(l[1])
n = int(l[2])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    x = (N // B) * B - 1
    if x == -1:
        x = N
    res = (A * x) // B - A * (x // B)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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


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

high = n
low = 0
while high - low >= 1:
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) <= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(max(f(int(low)),f(int(high))))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

ans = int(A * ans_n / B) - A * int(ans_n / B)
print(ans)

Submission status: Accepted

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

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

ans = int((A/B)*x)
print(ans)

Submission status: Accepted

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

if n >= b-1:
    x = b-1
else:
    x = n
print((a*x)//b - a * (x//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-a*((b-1)//b))

Submission status: Accepted

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

def Ans(x):
    s=math.floor(a*x/b)
    t=a*math.floor(x/b)
    return s-t

ans=0
print(Ans(min(b-1,n)))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B,N=mis()
    if N>=B:
        x=B-1
    else:
        x=N
    print(A*x//B - A*(x//B))


main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
def formula(x):
    return math.floor(A*x/B)-(A*math.floor(x/B))
A,B,n=[int(x) for x in input().split()]
if(n<=B-1):
    x=n
else:
    x=B-1
maxi = formula(x)
print(maxi)

Submission status: Accepted

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


ans = (a*n)//b-a*(n//b)
if n >= 1:
    ans2 = (a*(n-1))//b - a*((n-1)//b)
else:
    ans2 = 0
if n >= 2:
    ans3 = (a*(n-2))//b - a*((n-2)//b)
else:
    ans3 = 0
if n >= 3:
    ans4 = (a*(n-3))//b - a*((n-3)//b)
else:
    ans4 = 0

if b <= n:
    ans5 = (a*(b-1))//b - a*((b-1)//b)
else:
    ans5 = 0
print(max(ans,ans2,ans3,ans4,ans5))

Submission status: Accepted

Solution code:
a,b,n = map(int,input().split())
def floor(a,b,x):
    return a*x//b - a*(x//b)

if n < b:
    print(floor(a,b,n))
else:
    print(floor(a,b,b-1))

Submission status: Accepted

Solution code:
import math

a,b,n=map(int,input().split(' '))
ans=0
x=min(n,b-1)
q=math.trunc(a*x/b)-a*math.trunc(x/b)
if ans<q:
    ans=q
print(int(ans))

Submission status: Accepted

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

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

def f(t):
    return int(A*t)-A*int(t)

if N >= B:
    print(f((B-1)/B))
else:
    print(f(N/B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(1, a+1):
    x = math.ceil(i*b/a)-1
    if x <= n:
        diff = math.floor(a*x/b) - a*math.floor(x/b)
        ans = max(ans, diff)
    elif n < x:
        diff = math.floor(a*n/b) - a*math.floor(n/b)
        ans = max(ans, diff)
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,N = LI()

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

d,m = divmod(N+1,B)
x1 = max(d*B-1,0)
x2 = N

print(max(calc(x1),calc(x2)))

Submission status: Accepted

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

def calc(a, b, x):
    # print(a, b, x, math.floor(a*x/b), math.floor(x/b))
    return math.floor(a*x/b) - a * math.floor(x/b)
    
ans = 0
max_x = b
if b > n:
    max_x = n
for x in range(1, max_x+1)[::-1]:
    r = calc(a, b, x)
    if r > ans:
        ans = r
        break

print(ans)

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
import numpy as np
a,b,n=list(map(int,input().split()))

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

if n>=b:
  print(func(a,b,b-1))
else:
  print(func(a,b,n))

Submission status: Accepted

Solution code:
from math import ceil,floor

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

t1 = f(a, b, n)
t2 = f(a, b, max(1, n - n%b - 1))
t = max(t1, t2)

print(t)

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,n = myinput()

if b==1:
    print(0)
    exit()
    
def mycalc(a,b,x):
    return floor((a*x)/b) - a*floor(x/b)

if n<b:
    ans = mycalc(a,b,n)
else:
    ans = mycalc(a,b,b-1)

print(ans)

Submission status: Accepted

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


def solve(A: int, B: int, N: int):

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


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 == 1:
    print(0)
else:
    ans = (A * N) // B - A * (N // B)
    for a in range(A):
        x = B * a + (B - 1)
        if x > N:
            break
        test = (A * x) // B - A * (x // B)
        ans = max(ans, (A * x) // B - A * (x // B))
    print(ans)

Submission status: Accepted

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

x = min(b-1, 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())
x=[]
AB=A/B
if B==1:
    print("0")
elif N<B:
    #x.append(math.floor(AB*N-1)-A*(N//B)
    print(math.floor(AB*N))
else:
    x=[math.floor(AB*N)-A*(N//B)]
    for i in range(N//B):
        x.append(math.floor(AB*((i+1)*B-1))-i)
    print(max(x))

Submission status: Accepted

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

ans = 0
if b > n:
    x = n
    ans = int(a * x // b) - int(a * (x // b))
else:
    x = n
    ans1 = int(a * x // b) - int(a * (x // b))
    x = (n//b)*b-1
    ans2 = int(a * x // b) - int(a * (x // b))
    ans = max(ans1,ans2)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
A,B,N= map(int, input().split())
ans = 0
if N>=B:
    i = B-1
else:
    i = N
d = (math.floor((A*i)/B) - A *math.floor(i/B))
print(d)

Submission status: Accepted

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

answer = 0
temp = 0

if N >= B:
    answer = A*(B-1) // B - A * ((B-1)//B)

else:
    answer = A*N //B - A * (N//B)

print(answer)

Submission status: Accepted

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