Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = (A * N) // B - A * (N // B)
for i in ps:
  if N < i: continue
  for j in range(1, 10 ** 4 + 1):
    x = i * j
    if N < x: continue
    res = max(res, (A * x) // B - A * (x // B))
for x in range(1, min(N, 10 ** 4)):
  res = max(res, (A * x) // B - A * (x // B))
print(res)

Submission status: Accepted

Solution code:
a,b,n=map(int,input().split())
x_kouho=[]
count=1
if b==1:
  res=0
else:
  while count<=n//b:
    x_kouho.append(b*count-1)
    count+=1
  if not x_kouho:
    x_kouho.append(n)

  res=0
  for i in range(0,len(x_kouho)):
    keep=x_kouho[i]
    kept=(a*keep)//b-a*(keep//b)
    if kept>res:
      res=kept
print(res)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if b == 1:
    print(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import sqrt,floor,ceil

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

if(b>n):
    x=a*n
    print(floor(x/b))
elif(b==n):
    x=a*(n-1)
    x1=floor(x/b)
    y=floor(x/b)-a
    print(max(x1,y))
else:
    x=a*(b-1)
    print(floor(x/b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n < b:
    k = n
else:
    k = b-1

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

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)
# ans = A * ((X/B) %1) - (A*X/B)%1
print(int(ans))

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(b-1, n)))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,math
def input():
    return sys.stdin.readline()[:-1]
A,B,N = map(int,input().split(' '))

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

Submission status: Accepted

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

sub = min(b, n)
if b <= n:
    sub -= 1
ans = (a * sub) // b - (a * (sub // b))
print(ans)

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 b==1:print(0);exit()
mul=(n+1)//b
x=max(1,mul*b-1)
print(max((a*x)//b-a*(x//b),(a*n)//b-a*(n//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:
A, B, N = map(int, input().split())

if N < B:
    ans = (A*N)//B
else:
    x = B-1
    v1 = (A*x)//B
    v2 = A*(x//B)
    ans = v1-v2

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    A, B, N = map(int, input().split())
    
    if N >= B-1:
        return (A*(B-1))//B - A*((B-1)//B)
    
    return (A*N)//B - A*(N//B)


print(main())

Submission status: Accepted

Solution code:
import math
def LI():return list(map(int,input().split()))

a,b,n=LI()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

A = None
B = None
N = None

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

def main():
    global A,B,N
    A,B,N = map(int, input().split())
    if B > N:
        return calc(N)
    else:
        #mmax = 0
        #for x in range(N+1):
        #    mmax = max(mmax, calc(x))
        #print(mmax)
        return calc(B-1)

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

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, B, N = getlist()
	if N < B:
		ans = int(A * N // B)
	else:
		ans = int(A * (B - 1) // B)
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
A, B, N = map(int, input().split())
# for x in range(N+1+20):
#     a = int(A * x / B) - A * int(x / B)
#     print(a)
if N < B-1:
    x = N
else:
    x = B - 1
print(int(A * x / B) - A * int(x / B))

Submission status: Accepted

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

if n >= b:
  n = (n+1)//b*b-1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
li = list(map(int,input().split()))
a = li[0]
b = li[1]
n = li[2]
if b-1<=n:
    t = b-1
else:
    t=n
print(a*t//b - a*(t//b))

Submission status: Accepted

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

a,b,n = map(int,input().split())
if b==1 or a==1:
    print(0)
    exit()
if n<b:
    print(func(a,b,n))
else:
    print(func(a,b,b-1))

Submission status: Accepted

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

if __name__=='__main__':
    main()

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

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

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(1000000)

def slow_solve(A, B, N):
    ans = 0
    for x in range(1, N+1):
        d = math.floor( (x * A) / B) - A * math.floor(x / B)
        ans = max(ans,d)
    return ans

def solve(A, B, N):
    x = min(N, B - 1)
    d = math.floor( (x * A) / B) - A * math.floor(x / B)
    return d

#
# for A in range(1, 100):
#     print(A)
#     for B in range(1, 100):
#         for N in range(1, 100):
#             if slow_solve(A, B, N) != solve(A, B, N):
#                 print(A, B, N)
#                 print("fail")
#                 print(slow_solve(A, B, N))
#                 print(solve(A, B, N))
#                 exit(1)
#
# print("OK")

if __name__ == "__main__":
    A, B, N = tuple(map(int, input().split(" ")))
    print(solve(A, B, N))

Submission status: Accepted

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

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

Submission status: Accepted

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

num=N//B
if num==0:
    n=N
else:
    n=B*num-1

#print(n)
temp1=(A*n)/B//1
temp2=A*((n/B)//1)

print(int(temp1-temp2))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  a,b,n = map(int,input().split())
  ans = 0
  if b > n:
    ans = a*n // b
    print(ans)
  else:
    ans = a*(b-1)//b
    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-(x//B)*A)

Submission status: Accepted

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

from math import floor
ans=0

if b>n:
    x=n
    print(floor(a*x/b)-a*floor(x/b))
    exit()
cnt=0    
for x in range(b-1,n+1,b):
    tmp=floor(a*x/b)-a*floor(x/b)
    ans=max(ans,tmp)
    cnt+=1
    if cnt>10**7:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:


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

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

x = min(b-1,n)
print(floor(x))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a, b, n = [int(x) for x in stdin.readline().rstrip().split()]
    if n >= b:
        print((a*(b-1))//b)
    else:
        print((a*n)//b)
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:
from math import floor
A, B, N = map(int, input().split())
x = 0
if N >= B - 1:
  x = B - 1
else:
  x = N
print(floor(A*x/B)-A*floor(x/B))

Submission status: Accepted

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

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

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())
ans=0
c = 0

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

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

Submission status: Accepted

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

if n<=b-1:
  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:
x, y, z = map(int, input().split())
if y - 1 >= z:
	print((x * z) // y - x * (z // y))
else:
	w = (z // y) * y - 1
	print(max((x * w) // y - x * (w // y), (x * z) // y - x * (z // y)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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



    


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

print(int(a*x/b))

Submission status: Accepted

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

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:
a,b,n = map(int,input().split())
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:
from sys import stdin
import math
import fractions

a, b, n = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b,n = na()

x = n if b > n else (n//b)*b-1

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

print(ans)

Submission status: Accepted

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

x = min(n, b - 1)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
abn=list(map(int, input().split()))
a=abn[0]
b=abn[1]
n=abn[2]
if n>=b:
    n=b-1
axb=(a*n)//b
print(axb)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

Submission status: Accepted

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

def input_one_number():
    return int(input())

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

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

A,B,N = input_multiple_number()


ans = 0

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


wk = A*x//B - x//B*A
ans = max(ans,wk)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if B <= N:
    x = B - 1
else:
    x = 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()]


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

Submission status: Accepted

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

ans1=calc(a,b,min(b-1,n))
print(ans1)

Submission status: Accepted

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

x=b-1
if x>n:
    x=n
p=a*x//b
q=x//b
print(p-q)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

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

ans = 0

if A == 1 or B ==1:
  ans = 0
else:
  ans = cal_ans(min(N,B-1))

print(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:
A, B, N = map(int,input().split())
def f(x):
    return (A*x)//B-A*(x//B)
"""
for x in range(N+1):
    print(x,f(x))
"""
if B-1 <= N:
    print(f(B-1))
else:
    print(f(N))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(left - right)

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:
from math import floor
import sys
a,b,n = map(int,sys.stdin.readline().split())
d = 1
if n<b:
	d = b-n
print(floor(a - (a*d)/b))

Submission status: Accepted

Solution code:
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
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

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

Submission status: Accepted

Solution code:
from itertools import count

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
# MOD = 998244353


A, B, N = read_n_item()

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

Submission status: Accepted

Solution code:

MOD = 10 ** 9 + 7

def main():
    for _ in inputt(1):
        A, B, N = inputi()
        N = min(N, B - 1)
        print(N * A // B)

# region M


# region import

from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(1000)

# endregion

# region fastio

BUFSIZE = 8192
class FastIO(io.IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = io.BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(io.IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
    if args:
        sys.stdout.write(str(args[0]))
        split = kwargs.pop("split", " ")
        for arg in args[1:]:
            sys.stdout.write(split)
            sys.stdout.write(str(arg))
    sys.stdout.write(kwargs.pop("end", "\n"))
def debug(*args, **kwargs):
    print("debug", *args, **kwargs)
    sys.stdout.flush()
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip()
inputt = lambda t = 0: range(t) if t else range(int(input()))
inputs = lambda: input().split()
inputi = lambda k = int: map(k, inputs())
inputl = lambda t = 0, k = lambda: list(inputi()): [k() for _ in range(t)] if t else list(k())

# endregion

# region bisect

def len(a):
    if isinstance(a, range):
        return -((a.start - a.stop) // a.step)
    return builtins.len(a)
def bisect_left(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if key(a[mid]) < x: lo = mid + 1
        else: hi = mid
    return lo
def bisect_right(a, x, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    while lo < hi:
        mid = (lo + hi) // 2
        if x < key(a[mid]): hi = mid
        else: lo = mid + 1
    return lo
def insort_left(a, x, key = None, lo = 0, hi = None):
    lo = bisect_left(a, x, key, lo, hi)
    a.insert(lo, x)
def insort_right(a, x, key = None, lo = 0, hi = None):
    lo = bisect_right(a, x, key, lo, hi)
    a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right
def index(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    if key == None: key = do_nothing
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi and key(a[i]) == x: return a[i]
    if default != None: return default
    raise ValueError
def find_lt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_le(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo < i <= hi: return a[i - 1]
    if default != None: return default
    raise ValueError
def find_gt(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_right(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError
def find_ge(a, x, default = None, key = None, lo = 0, hi = None):
    if lo < 0: lo = 0
    if hi == None: hi = len(a)
    i = bisect_left(a, x, key, lo, hi)
    if lo <= i < hi: return a[i]
    if default != None: return default
    raise ValueError

# endregion

# region csgraph
# TODO

class Tree:
    def __init__(n):
        self._n = n
        self._conn = [[] for _ in range(n)]
        self._list = [0] * n
    def connect(a, b):
        pass

# endregion

# region ntheory

class Sieve:
    def __init__(self):
        self._n = 6
        self._list = [2, 3, 5, 7, 11, 13]
    def extend(self, n):
        if n <= self._list[-1]: return
        maxbase = int(n ** 0.5) + 1
        self.extend(maxbase)
        begin = self._list[-1] + 1
        newsieve = [i for i in range(begin, n + 1)]
        for p in self.primerange(2, maxbase):
            for i in range(-begin % p, len(newsieve), p):
                newsieve[i] = 0
        self._list.extend([x for x in newsieve if x])
    def extend_to_no(self, i):
        while len(self._list) < i: 
            self.extend(int(self._list[-1] * 1.5))
    def primerange(self, a, b):
        a = max(2, a)
        if a >= b: return
        self.extend(b)
        i = self.search(a)[1]
        maxi = len(self._list) + 1
        while i < maxi:
            p = self._list[i - 1]
            if p < b:
                yield p
                i += 1
            else: return
    def search(self, n):
        if n < 2: raise ValueError
        if n > self._list[-1]: self.extend(n)
        b = bisect(self._list, n)
        if self._list[b - 1] == n: return b, b
        else: return b, b + 1
    def __contains__(self, n):
        if n < 2: raise ValueError
        if not n % 2: return n == 2
        a, b = self.search(n)
        return a == b
    def __getitem__(self, n):
        if isinstance(n, slice):
            self.extend_to_no(n.stop + 1)
            return self._list[n.start: n.stop: n.step]
        else:
            self.extend_to_no(n + 1)
            return self._list[n]

sieve = Sieve()
def isprime(n):
    if n <= sieve._list[-1]:
        return n in sieve
    for i in sieve:
        if not n % i: return False
        if n < i * i: return True
prime = sieve.__getitem__
primerange = lambda a, b = 0: sieve.primerange(a, b) if b else sieve.primerange(2, a)
def factorint(n):
    factors = []
    for i in sieve:
        if n < i * i: break
        while not n % i:
            factors.append(i)
            n //= i
    if n != 1: factors.append(n)
    return factors
factordict = lambda n: Counter(factorint(n))

# endregion

# region main

if __name__ == "__main__":
    main()

# endregion


# endregion

Submission status: Accepted

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

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

# for x in range(1, N + 1):
#     tmp1 = (A * x) // B
#     tmp2 = A * (x // B)
#     print("{}: {} - {} = {}".format(x, tmp1, tmp2, tmp1 - tmp2))

# x == B - 1??
x = min(B - 1, N)
tmp1 = (A * x) // B
tmp2 = A * (x // B)
print(tmp1 - tmp2)

Submission status: Accepted

Solution code:
import math
a,b,n=map(int,input().split())
l=[]
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:
a, b, n = map(int, input().split())
i = min(b - 1, n)
print((a * i) // b - a * (i // b))

Submission status: Accepted

Solution code:
A,B,N = map(int,input().split())
if B <= N:
    X = B-1
elif B > N:
    X = N
print(int((A*X)/B) - A*int(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:
a,b,n=map(int,input().split())
ans=min(n,b-1)
print(a*ans//b-ans//b)

Submission status: Accepted

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


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


if B == 1:
    print(0)
elif B > N:
    print(calc(N))
else:
    print(calc(B - 1))

Submission status: Accepted

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