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

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(" "))
ans = 0
x = min(B-1,N)
floor = int(A*x/B) - A * int(x/B)
print(floor)

Submission status: Accepted

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

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))
else:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))
    

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

ans = max(buf)
print(ans)

Submission status: Accepted

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

print(max)

Submission status: Accepted

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

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

x = min(B-1,N)

print(floor_calc(x))

Submission status: Accepted

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - 1
    v=min(t,u)
    ans=f(v)
print(ans)

Submission status: Accepted

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

x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
print(f(x3))

Submission status: Accepted

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

s = min(b- 1, n)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
A,B,N = MI()

mini = min(B-1,N)
s = math.floor(A*mini/B) - A * math.floor(mini/B)
print(s)

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)-A*math.floor(x/B)
print(int(ans))

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 matplotlib.pyplot as plt

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



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


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
 
a,b,n=n1()
import math
if b<=n:
    i=b-1
else:
    i=n
m=math.floor((a*i)/b)-a*math.floor(i/b)
print(m)

Submission status: Accepted

Solution code:
a,b,n = map(int, input().split())
# ans = []
if(b-1<=n):
    i = b-1
else:
    i = n
# for i in range(0, n):
ans = (a*i)//b - a*(i//b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
 
a,b,n=n1()
import math
if b<=n:
    i=b-1
else:
    i=n
m=math.floor((a*i)/b)-a*math.floor(i//b)
print(m)

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

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:


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


# n = int(input())
a, b, n = [int(s) for s in input().split(" ")]
solve()

Submission status: Accepted

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

from math import floor

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

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


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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
import math
A,B,N = (int(x) for x in input().split())
a = min(B-1,N)
ans = math.floor(A*a/B) - A*math.floor(a/B)
print(ans)

Submission status: Accepted

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

    if n < b:
        print(a * n // b)
        exit()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:


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

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

X = N
Y = min(B-1,N)

print(f(Y))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

#if a == 1 or b == 1 or b == n:
#    print(0)
#else:
print(ans)

Submission status: Accepted

Solution code:
import math
import random

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

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(8000000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Submission status: Accepted

Solution code:
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:
import math
A, B, N = (int(i) for i in input().split())  

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

print(func(A, B, min(N, B-1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
from math import floor
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = floor(a * x / b) - a * floor(x / b)
print(ans)

Submission status: Accepted

Solution code:
import math
A,B,N=map(int,input().split())
D=int(A*B/math.gcd(A,B))
maxi=0
if B-1<=N:
  print(int((B-1)%B*A/B-(A*(B-1))%B/B))
else:
  print(int(N%B*A/B-(A*N)%B/B))

Submission status: Accepted

Solution code:
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:
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 sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, n = MII()
    f = lambda x: divf(a*x,b) - a*divf(x,b)
    print(f(min(b-1, n)))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
A,B,N=list(map(int,input().split()))
N=min(B-1,N)
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(N * A // B - A * (N // B))
else :
  print((B-1) * A // B - A * ((B-1) // B))

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
a = l[0]
b = l[1]
n = l[2]

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

max = 0
if b == 1:
    max = 0
elif n <= b-1:
    max = floor(a,b,n)
elif n > b-1:
    for i in range(b-1,n+1,b):
        c = floor(a,b,i)
        if c >= max:
            max = c

print(max)

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

    else:
        right = tmp_right
        if ans < f_right:
            ans = f_right
            num = tmp_right


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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
a, b, n = map(int, input().split())
 
if n >= b:
    x = b-1
else:
    x = n
 
print(a*x//b-a*(x//b))

Submission status: Accepted

Solution code:
import sys
from math import sqrt, floor

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


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


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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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*(x//B))

Submission status: Accepted

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
x=min(B-1,N)
ans = int((A*x)/B)-A*int(x/B)
print(ans)
# if N >= 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:
def f(A,B,x):
    return (((A*x)//B)-(A*(x//B)))
def main():
    A,B,N=map(int,input().split())
    x=min(N,B-1)
    print(f(A,B,x))
if __name__=='__main__':
    main()

Submission status: Accepted

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

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


print(ans)

Submission status: Accepted

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


##########
if __name__ == "__main__":
    d()

Submission status: Accepted

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

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

import math

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

if __name__ == '__main__':
    a, b, n = map(int, input().split())
    if b > n:
        m = calc(a, b, n)
    else:
        m = calc(a, b, b - 1)
    print(m)

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

Submission status: Accepted

Solution code:
import sys
from math import sqrt, floor

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


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


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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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

ans = function(0)
for i in range(b):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8

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

z = 0

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

print("{}".format(z))

Submission status: Accepted

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

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)- a * math.floor(x/b)
print(ans)

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

# 答えが最大になるｘ
if math.floor(N / B) > 0:
    ans_x = B - 1
else:
    ans_x = N

l = math.floor((A * ans_x) / B)
r = A * math.floor(ans_x / B)

ans = l - r

print(ans)

Submission status: Accepted

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

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

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

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:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, n = LI()
if b - 1 <= n:
    x = b - 1
else:
    x = n
print(a * x // b - a * (x // b))

Submission status: Accepted

Solution code:
import math
S =  list(map(int,input().split()))
A = S[0]
B = S[1]
N = S[2]
if N<B:
    print(math.floor(A*N/B)-math.floor(N/B)*A)
else:
    print(math.floor(A*(B-1)/B)-math.floor((B-1)/B)*A)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
import sys
from math import sqrt, floor

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


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


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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
if b[2]>b[1]-1:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
else:
    check = math.floor((b[0]*b[2])/b[1]) - b[0]*math.floor(b[2]/b[1])
if check>ans:
    ans=check
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	ni = min(n,b-1)
	f = math.floor((a*(ni))/b)
	s = math.floor((ni)/b)
	temp = int(f) - (a*int(s))
	ans = temp
	# if(n>b):
	# 	f = math.floor((a*(b-1))/b)
	# 	s = math.floor((b-1)/b)
	# 	temp = int(f) - (a*int(s))
	# 	ans = temp
	# else:
	# 	f = math.floor((a*(n))/b)
	# 	s = math.floor((n)/b)
	# 	temp = int(f) - (a*int(s))
	# 	ans = temp
	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))
else:
    print(math.floor(a*n/b))

Submission status: Accepted

Solution code:
import math

a,b,n = map(int, input().split())
tmp = int(n/b)
result = 0
if tmp != 0:
    result = b - 1
else:
    result = n
print(math.floor((a*result)/b) - a*math.floor(result/b))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import math


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

    x = min(b-1, n)

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

def fl(i):
  return ((A * i) // B) - (A * (i // B))

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

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())
S = 0
n = N // B
r = N % B
if B > N:
    S = (A*N)//B
else:
    if  r == 0:
        S = (A*(N-1))//B - A * ((N-1)//B)
    elif r == B - 1:
        S = (A*N)//B - A * (N//B)
    else:
        S = (A*(n*B-1))//B - A * ((n*B-1)//B)

print(S)

Submission status: Accepted

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=a*n//b-a*(n//b)
x=n//b*b-1
if x<0:
    x=n-1
cand2=a*x//b-a*(x//b)
print(max(cand2,cand1))

Submission status: Accepted

Solution code:
import math

def main(A, B, N):
    x = min(B-1, N)
    answer = math.floor(A * x / B) - A * math.floor(x / B)
    print(answer)

if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    main(A, B, N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    A,B,N = [int(item) for item in input().split()]

    def func(x):
        first = int(A * x / B)
        second = A * int(x/B)
        return first - second

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

def solve(A: int, B: int, N: int):
    x = min(B-1, N)
    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 = [int(x) for x in input().split()]

y = min(b-1, n)

print((a*y)//b)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

import math as mt

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

x = min(N, B-1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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 = map(int, input().split())
ref = min(b - 1, n)

ans = a*ref//b - a*(ref//b)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

A,B,N = FLI()

def f(x):
  return (A*x)//B - A * (x//B)
max = 0
x = min(B-1,N)

print(f(x))

Submission status: Accepted

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

cnt=0

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:
def main():
    from builtins import int, map, list, print, max
    import sys, math
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, N = input_number_list()
    x = min(B - 1, N)
    print(math.floor(A * x / B) - A * math.floor(x / B))


if __name__ == '__main__':
    main()

Submission status: Accepted

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