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:
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    a,b,n = map(int,input().split())
    x = -INF
    if b - 1 <= n:
        x = a*(b - 1)//b - a*((b - 1)//b)
    y = a*n//b - a*(n//b)
    print(max(x,y))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
a,b,n = list(map(int,input().split()))
x = 1
temp = 0
res = 0

if (b - 1) > n:
    x = n
    # for i in range(n):
    #     temp = math.floor((a*x)/b) - a * math.floor(x/b)
    #     print(str(x) + " " + str(temp))
    #     if res < temp:
    #         res = temp
    #     x += 1
else:
    x = (b - 1)

res = math.floor((a*x)/b) - a * math.floor(x/b)
print(res)

Submission status: Accepted

Solution code:
A,B,N=map(int,input().split())
if B==1:
    print(0)
    exit()

if N==1:
    ans=(A//B)-A*(1//B)
    print(ans)
    exit()
if A==1:
    print(0)
    exit()

if B<N:
    val=B-1
    ans=(A*val)//B-A*(val//B)
elif N<B:
    val=N
    #print("ON")
    ans=(A*val)//B-A*(val//B)
else:
    val=B-1
    ans=(A*val)//B-A*(val//B)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

ans = p

print(ans)

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    n = kwargs["n"]

    for i in range(min(b, n), -1, -1):
        res = a * i // b - a * (i // b)

        if res > 0:
            break

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"], kwargs["n"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Accepted

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

x = (n//b)*b - 1

if x == -1:
    x = n

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if B > N:
    ans = (A*N)//B - (A * (N//B))
else:
    moge = B*2 - 1
    ans = (A*moge)//B - (A*(moge//B))
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from math import floor
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
A, B, N = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

if floor(N/B)==0:
    print(floor(N*A/B))
    exit()
if B==1:
    print(0)
    exit()

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())
m = min(B-1,N)
num = math.floor((A*m)/B) - A * math.floor(m / B)
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

if b > n:
     x = n
else:
    x = b-1

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

Submission status: Accepted

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

if N>B:
    x = B -1
else:
    x = N
D = []

if N > 20:
    w = N % 15 + 5
elif N > 4:
    w = N-1
else:
    w = N
for i in range(w):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split())
if n <= b - 1:
    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=[int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
import math

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

x = min(N, 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())
ans = 0
# floor(a * x / b)
# = floor(a * floor(x / b) + a * (x / b - floor(x / b)))
# = a * floor(x / b) + floor(a * (x / b - floor(x / b))))
print(int(a * min(b - 1, n) / b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math


def main():
    input = sys.stdin.readline
    a, b, n = (int(i) for i in input().split())

    x = min(b - 1, n)

    res = (a * x) // b - a * (x // b)

    print(res)


main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B, N = Scanner.map_int()

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


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if B == N:
    x = N - 1
elif 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().strip().split(" ") ) ;


x = B -1 ; 
if x > N :
	x = N ; 
y = int ( ( A * x ) // B ) - A * int ( x //B ) ;
print ( y ) ;

Submission status: Accepted

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

x = min(b-1, n)

print(a*x//b)

Submission status: Accepted

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

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

print(max)

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split())
x = min(n, b)
while x % b == 0 and b != 1:
    x -= 1
if b == 1:
    print(0)
else:
    i = x
    # print(a * i // b - a * int(i / b), a * i // b, a * int(i / b))
    print(a * x // b)
# print(x)
# ans = 0
# for i in range(1, n + 1):
#     ans = max(ans, a * i // b - a * int(i / b))
#     # print(i, ans, a * i // b - a * int(i / b), a * i // b, a * int(i / b))
# print(ans)

Submission status: Accepted

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

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

x = min(N, B-1)
ans = f(x)
if N >= B-1:
    ans = A + (-A//B)

print(ans)

Submission status: Accepted

Solution code:

import numpy as np

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

def calc(x):
    return int( np.floor( ( A * x ) / B ) - A * np.floor( x / B ) )

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

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


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


a, b, n = sp()
low, high = 1, n
answer, index = -inf, 0
while low <= high:
    mid = (low + high) // 2
    temp = calc(mid)
    if temp > answer:
        answer = temp
        low = mid + 1
    else:
        high = mid - 1
if n > pow(10, 7):
    for i in range(1, pow(10, 5)):
        answer = max(answer, calc(i))
    for i in range(n, n-pow(10, 5)-1, -1):
        answer = max(answer, calc(i))
out(answer)

Submission status: Accepted

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

a = A // B 
b =  A % B
c = N % B if N < B else B-1
print(a * c + int(b*c/B))

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

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

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

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

if N>=B:
    N=B-1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())

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

if B-1<=N:
  print(function(B-1))
else:
  print(function(N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b,n = 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
def D():
    A, B, N = map(int, input().split())
    if N >= B:
        print(A*(B-1)//B - A*((B-1)//B))
        return
    x = N % B
    print(A*x//B - A*(x//B))
D()

Submission status: Accepted

Solution code:
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    a,b,n=mdata()
    print(math.floor(a*min(n,b-1)/b))



if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, n = nm()

    x = min(b - 1, n)
    ans = math.floor(a * x / b)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

def read_int_list():
    return list(map(int,input().split(' ')))

def read_s_list_loop(n):
    return [input() for _ in range(n)]
import math
A,B,N = read_int_map()

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

'''
for i in range(1,N+1):
    print(i, math.floor(A*i/B)-A*math.floor(i/B))
'''

Submission status: Accepted

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

def solve(A: int, B: int, N: int):
    x = min(N, B - 1)
    print(math.floor(A*x/B)-A*math.floor(x/B))
    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 N >= B:
    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 = 1
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):
    x = n-1
elif (b < n):
    x = b-1
elif (b > n):
    x = n

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

Submission status: Accepted

Solution code:
import math


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


def solve(A, B, N):
    if N >= B-1: 
        x = max(B - 1, 0)
    else:
        x = N
    y = math.floor(A * x / B) - A * math.floor(x / B)
    return y

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Submission status: Accepted

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

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

# generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    A, B, N = map(int, input().split())
    guy = solve(A, B, N)
    print(guy)

if __name__ == '__main__':
    main()

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:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict
from sys import exit
import math


def main():
    a,b,x = getList()
    if x < b:
        print(math.floor( (a*x) / b) - a * math.floor(x/b) )
    else:
        k = b - 1
        print(math.floor( (a * k) / b) - a * math.floor(k / b) )
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = 0

if N < B - 1:
    ans = math.floor(A * N / B) - A * math.floor(N / B)
else:
    c = B - 1
    cnt = 1
    while c <= N:
        cnt += 1
        t = math.floor(A * c / B) - A * math.floor(c / B)
        ans = max(ans, t)
        c += B
        if B < cnt:
            break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import *
a,b,n = map(int,input().split())
ans = a*n//b - a*(n//b)
mb = (n//b)*b-1
if(mb > 0):
	ans = max(ans,a*mb//b - a*(mb//b))
mbb = min(n,b-1)
ans = max(ans,a*mbb//b - a*(mbb//b))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


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

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

    if N < B:
        print(f(N))
        return

    print(f(B-1))




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
a, b, n = get_ints()
x = min(b-1, n)
ans = math.floor((a*x)/b) - (a * math.floor(x/b))
print(ans)


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,N=MI()
    y = (N+1)//B
    x = y*B-1
    # print(x)
    x = min(x,N)    

    def f(x):
        # print((A*x)//B, A*(x//B))
        return (A*x)//B - A*(x//B)
    # print(x,y)#####
    x=max(0,x)
    print(max(f(x),f(N),f(N-1)))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if N < B:
  print(fl(N))
  exit()
print(fl(B-1))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, N = lr()
if B <= N:
    answer = 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>=1:
    x=b-1
else:
    x=n
print(int(a*x/b)-a*int(x/b))

Submission status: Accepted

Solution code:
import sys
import math
input = lambda:sys.stdin.readline().strip()
def f(a,b,x):
    return (a*x)//b-(a*(x//b))
a,b,n = map(int,input().split())
if n<b-1:
    print(f(a,b,n))
else:
    print(f(a,b,b-1))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

print(x*A//B)

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())

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

if  n >= b:
    r = b - 1
else:
    r = n
    
ans = (a * r) // b

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

x = b - 1
if n < x:
    x = n

ans = 0

while x > 0:
    l = (a * x) // b
    r = a * (x // b)
    ans = max(ans, l - r)
    x -= b

print(ans)