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: Time Limit Exceeded

Solution code:
import math

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

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

i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split())
max_i = 0
for i in range(1, n+1):
    tmp = math.floor(a*i/b)- a * math.floor(i/b)
    if tmp > max_i:
        max_i = tmp
print(max_i)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
print(max([(a*i)//b - a*(i//b) for i in range(n + 1)]))

Submission status: Time Limit Exceeded

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
c=-(10**18)
for x in range(1,N+1):
    c=max(c,main(x))
print(c)

Submission status: Time Limit Exceeded

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])
max = 0
for x in range(int(N)+1):
    S = int(A * x / B) - A * int(x / B)
    
    if max<S:
        max = S
print(max)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
a,b,n = map(int,input().split())
ans = 0
dd = 0
for i in range(n+1):
    y = (floor(a*i/b) - a*floor(i/b))
    if y >= ans:
        dd = 1
        ans = y
    else:
        print(ans)
        exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

a,b,n = map(int,input().split())
ans = math.floor((a*1)/b) - a*math.floor(1/b)
for i in range(1,n+1):
    d = math.floor((a*i)/b) - a*math.floor(i/b)
    if ans > d:
        break
    ans = max(ans,d)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = (int(x) for x in input().split())
max = 0
for x in range(0,N+1):
    ans = math.floor(A*x/B) - A * math.floor(x/B)
    if ans > max:
        max = ans
print(max)

Submission status: Time Limit Exceeded

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

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

ans = 0
for i in range(n+1):
    if floorf(i)>ans:
        ans=floorf(i)
        
print(ans)

Submission status: Time Limit Exceeded

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

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

print(max(floor(A, B, n) for n in range(N + 1)))

Submission status: Time Limit Exceeded

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

    r = 0
    for i in range(n+1):
        r = max(r, floor(a*i/b) - floor(i/b)*a)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
maxi = -100000
for i in range(0,N+1):
    maxi = max(math.floor(A*i/B)-A*math.floor(i/B),maxi)
print(maxi)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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


ans = - 10 ** 9

for i in range(1, n+1):
    m = floor(a*i/b) - a*floor(i/b)
    ans = max(ans, m)
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,n=map(int,input().split())
x=min(b-1,n) #上記よりxとしてmin(B-1,N)を選ぶのが最善
print((a*x)//b-a*(x//b))

Submission status: Accepted

Solution code:
def f(a, b, n):
    if b == 1:
        print(0)
    else:
        Max = 0
        step = 1 if b // a ==  0 else b // a
        for x in range(b // a, n + step, step):
            res = (a * x) // b - a * (x // b)
            if res > Max:
                Max = res
        print(Max)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if B <= N:
    N = B - 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

num = min(b-1,n)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def main():
    A, B, N = map(int, input().split())
    x = min([B-1, N])
    print(int(math.floor(A * x / B) - A * math.floor(x / B)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

n = min(N, B-1)

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

Submission status: Accepted

Solution code:

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

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

x = min(n, b-1)

print(f(x, a, b))

Submission status: Accepted

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

x = min(N, B-1)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

k = max(0,(n - b + 1) // b)
k = min(n,k * b + b - 1)

print((a * k) // b - a * (k // 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())

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

    print(f(a, b, x))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))
def inNL(n):
    return [list(map(int,input().split())) for i in range(n)]

a,b,n = inL()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

x=min(n,b-1)

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

print(ans)

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

print(ans)

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

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    a,b,n = LI()
    ans = 0
    def f(a,b,x):
        ans = (a*x)//b - a*(x//b)
        return ans
    if b-1<=n:
        ans = f(a,b,b-1)
    else:
        ans = f(a,b,n)
    print(ans)
main()

Submission status: Accepted

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

# floor(A x / B) - A * floor(x / B)
#
# x = B * x1 + x2  : (x2 < B) とする
#
# = floor(A (B*x1+x2) / B) - A floor((B*x1+x2) / B)
# = A x1 + floor(A x2 / B) - A x1
# = floor(A x2 / B)


def solve(A: int, B: int, N: int):
    if N >= B:
        x2 = B - 1
    else:
        x2 = N

    return (A * x2) // B


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    answer = solve(A, B, N)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	for j in range(len(b)):
		carry = 0
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def main():
	A, B, N = [int(x) for x in input().split(" ")]
	r = min([N, B - 1])
	print(bigint_divide(bigint_multiply(A, r), B))

main()

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:
import sys
import itertools
import math

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

i = min(B-1,N)


print(math.floor(A*i/B) - A * math.floor(i/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))
if B<=N:
    print(int(A*(B-1)/B)-A*int((B-1)/B))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

if n<b :
    ans=math.floor(a*n/b)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

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

Submission status: Accepted

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

x = min(B - 1, N)

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

Submission status: Accepted

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

from math import floor
if B - 1 <= N:
    x = B - 1
else:
    x = 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(((a*x)//b) - a*(x//b))

Submission status: Accepted

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

import math

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

Submission status: Accepted

Solution code:
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())
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().split())

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

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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


def main(A, B, N):
    if N < B:
        return f(A, B, N)
    else:
        return f(A, B, B - 1)


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

Submission status: Accepted

Solution code:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  A,B,N=map(int,pin().split())
  x=min(B-1,N)
  ans=int(A*x/B)-A*int(x/B)
  print(ans)
  return
main()
#解説AC

Submission status: Accepted

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


if '__main__' == __name__:
    resolve()

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:
def abc165d_floor_function():
    a, b, n = map(int, input().split())
    i = min(n, b-1)
    max_val = a*i//b - a*(i//b)
    # for i in range(1, n+1):
    #     v = a*i//b - a*(i//b)
    #     max_val = max(max_val, v)
    print(max_val)

abc165d_floor_function()

Submission status: Accepted

Solution code:
# 具体例を試す
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")

A,B,N = LI()
# ans = 0

# a = [0]*N

# for x in range(1,N+1):
#     # ans = max(ans,math.floor(A*x/B) - A * math.floor(x/B))
#     a[x-1]=math.floor(A*x/B) - A * math.floor(x/B)

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

Submission status: Accepted

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

Q = A // B
R = A % B

if R == 0:
    ans = Q * (B - 1)
elif B <= N:
    ans = R - 1 + Q * (B - 1)
else:
    ans = int(A * N / B) - A * int(N / B)

print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
a,b,n = readInts()
th = b-1
if n >= th:
    print(int(math.floor(a*th/b) - a * math.floor(th/b)))
else:
    print(int(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-1:
  print( (a*(b-1)) // b - a * ((b-1)//b))

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

Submission status: Accepted

Solution code:
import math
import decimal

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

if b<=n:
  x=decimal.Decimal(a*(b-1)/b)
  c=math.floor(x)
  print(c)

else:
  x=decimal.Decimal(a*n/b)
  c=math.floor(x)
  print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
 
 
def main():
    a,b,n=map(int, input().split())
    if b<=n:
        n=b-1
    print(((a*n)//b) - (a*(n//b)))
    

    
 
if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:

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




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

if N < B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*N/B) - A*math.floor(N/B)
    ans = max(temp1, temp2)

if N >= B:
    temp1 = math.floor(A*1/B) - A*math.floor(1/B)
    temp2 = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
    ans = max(temp1, temp2)

print(ans)

Submission status: Accepted

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
A, B, N = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)
x = 0
if N >= B:
    x = B - 1
else:
    x = N

print(int(A*x/B))

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,N=mi()

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

if __name__ == "__main__":
    main()

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:
import math

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

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

Submission status: Accepted

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

x = min(B-1, N)

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

print(ans)

Submission status: Accepted

Solution code:
from math import floor

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

if N // B >= 1:
    if B != 1:
        x = B - 1
    else:
        x = 1
else:
    x = N

#print(x)
result = floor(A * x // B) - A * floor(x / B)

print(result)

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

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

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

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())
x = min(N,B-1)
print(f(A,B,x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

# print(max)

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

if b>n:
    x=n
    ans=(a*x)//b -a*(x//b)

else:
    x=b-1
    ans=(a*x)//b -a*(x//b)

print(ans)

Submission status: Accepted

Solution code:
# x % B = q として、 q をできるだけ大きくすると qA//B が解
A, B, N = map(int, input().split())
q = min(B-1, N)
print(q*A//B)

Submission status: Accepted

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

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

print(max_L)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    A,B,N = [int(i) for i in input().split()]
    x = min(B-1,N)
    print(int(A*x/B)-A*int(x/B))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a, b, n = MAP()
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())

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

print(calc)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

c = min(b - 1, n)
#logging.debug(c)
print(int(((a * c) / b) // 1 - (a * ((c / b) // 1))))

Submission status: Accepted

Solution code:
import math

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

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

ans = math.floor(a * x / b)

print(ans)

Submission status: Accepted

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