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:
# D

import math
inp = input().split(' ')
A, B, N = int(inp[0]), int(inp[1]), int(inp[2])

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    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())

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

print(res)

Submission status: Accepted

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

# def getmax(A,B,N):
#     x1 = max(B * (N//B) - 1, 0)
#     x2 = N

#     resx1 = int(A*x1/B) - A* int(x1/B)
#     resx2 = int(A*x2/B) - A* int(x2/B)

#     return max(resx1, resx2)

# print(getmax(A,B,N))

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

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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

    l = f(0)
    e = f(N)

    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False
    def isOK2(mid):
        if f(mid) - e >= 0:
            return True
        else:
            return False

    ok = 0
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    ok = N
    ng = 0

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK2(mid):
            ok = mid
        else:
            ng = mid

    ans = max(ans, l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

print(max)

Submission status: Accepted

Solution code:
A,B,N=map(int, input().split())
answer=0
import math
if N < B:
    print(int(math.modf(N/B)[0]*A))
else:
    apple=min(B,N)
    startnum = B-1 if B>1 else 1
    for i in range(startnum,apple+1):
        newans=math.modf(i/B)[0]*A
        newans//=1
        answer=newans if newans>answer else answer
    print(int(answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import math



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

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
if num >= 100000:
    print(b-1)
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)

Submission status: Accepted

Solution code:
import sys
import math

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

floor = math.floor

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

def l(x):
    global A, B
    return floor(A*x/B)

def r(x):
    global A, B
    return A*floor(x/B)

def main():
    global A, B
    A, B, N = map(int, readline().split())
    #for i in range(0, 100):
    #    print('i:{}, l:{}, r:{}, f(i)={}'.format(i, l(i), r(i), f(i)))
    if B == 1:
        ans = 0
    elif N >= B:
        x = B - 1
        ans = f(x)
    else:
        x = N
        ans = f(x)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

  if n >= b-1:
    ans = F(b-1)
  else:
    ans = F(n)

  print(ans)

abc165_d()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max_score)

Submission status: Accepted

Solution code:
import math

def calc(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)
    
def main():
    A,B,N = [int(x) for x in input().split()]
    if N < B:
        print(calc(A,B,N))
    else:
        print(calc(A,B,B-1))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import floor,ceil
import fractions
import collections
import itertools
from collections import deque
A,B,N=map(int,input().split())

piv=B/A  #基本数

#for i in range(0,30):
#    print(A,i,B,floor(A*i/B)-A*floor(i/B))

#A<=Bなら
#0,0,.. 1,1,.. ... (A-1),(A-1),...が
#先頭から(B%A)の数字まではceil(piv)こ、あとはfloor(piv)こ

cnt=0
#print(ceil(piv)*(B%A))
if A<=B:
    if N>=B-1:
        print(A-1)
    else:
        if ceil(piv)*(B%A)>N:
            print(floor(N/ceil(piv)))
        else:
            N=N-ceil(piv)*(B%A)
            #print(N,N//floor(piv))
            cnt=(B%A)
            print(cnt+N//floor(piv))
else:  #A>B
    l=[0]
    for i in range(1,B):
        l.append(max(l[i-1],floor(A*i/B)-A*floor(i/B)))
    #print(l)
    if N>=len(l):
        print(l[len(l)-1])
    else:
        print(l[N])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,n=map(int,input().split())
l=[]
m=a//b
if b==1:
    print(0)
    exit()
if n>=b:
    for x in range(b-1,n+1,b):
        y=a*x//b-a*(x//b)
        #l.append(y)
        m=max(m,y)
    x=n
    y=a*x//b-a*(x//b)
    m=max(m,y)
else:
    x=n
    y=a*x//b-a*(x//b)
    #l.append(y)
    xx=n-1
    yy=a*xx//b-a*(xx//b)
    m=max(y,yy)


print(m)

Submission status: Accepted

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

if b > n:
    x = n
else:

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

print(ans)

Submission status: Accepted

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

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


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

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

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

    print(m)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
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())
ans = 0
if N < B:
    print(int(A*N/B))
else:
    print(int(A*(B-1)/B))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')



A, B, N = MI()

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

Submission status: Accepted

Solution code:
# 2020/05/02
# AtCoder Beginner Contest 165 - D

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

# Calc
if n >= b:
    ans = int(a * (b - 1) / b) - a * int((b-1) / b)
else:
    ans = int(a * n / b) - a * int(n / b)

# Output
print(ans)

Submission status: Accepted

Solution code:
a,b,n=[int(i) for i in input().split()]
p=a//b
q=a%b
mu=min(b-1,n)

print(p*mu+q*mu//b)

Submission status: Accepted

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

if N < B:
    print((A*N)//B)
else:
    qa, ra = divmod(A, B)
    rx = B-1
    print(qa*rx + (ra*rx)//B)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split())
import math
c = math.floor(a*n/b)
d = math.floor(n/b)
e = a*d
f = math.floor(a*(b-1)/b)
g = math.floor((b-1)/b)
h = a*g
if n < b:
  print(c - e)
else:
  print(f - h)

Submission status: Accepted

Solution code:
import math

a, b, n = map(int, input().split())
maxr = 0
minr = 0
ans = 0
if b < n:
    maxr = b + 1
    minr = abs(b - 1000000) if abs(b - 1000000) < b else 0
else:
    maxr = n + 1
    minr = abs(n - 1000000) if abs(n - 1000000) < n else 0
for i in range(minr, maxr):
    c = math.floor((a * i) / b) - math.floor(i / b) * a
    ans = max(ans, c)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def floor(a,b,n):
    if b == 1:
        print(0)
    elif n < b:
        print(int(a*n/b)-a*int(n/b))
    else:
        print(int(a*(b-1)/b))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = 0
if b > 10 ** 6:
    x = b - 1
    while x <= n:
        ans = max(ans,f(x))
        x += b
for x in range(n,max(1,n-2 * 10**6 -10),-1):
        ans = max(ans,f(x))
    
print(ans)

Submission status: Accepted

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

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    j=b-1
    num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
print(num)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


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


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

Submission status: Accepted

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

# process
x = 0
if B <= N:
    x = B-1
else:
    x = N

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

mn = min(B-1,N)
mx = int(A*mn/B)

print(mx)

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

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

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


a,b,n = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b,n)
print(ans)

Submission status: Accepted

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

ans = min (b - 1, n)

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

Submission status: Accepted

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


x = b-1

if b > n:
  res = int((a/b)*n)

else :
  res = int((a/b)*(b-1))
  
print(res)

Submission status: Accepted

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

if b > n:
    mod_ab = a%b
    #answer = 1/b (A*x - mod(x*mod(a,b),b)
    answer = (a*n)//b
else:
    x=b-1
    tmp_max=(a*x-(a*x)%b)
    answer=int(tmp_max/b)

print(answer)

Submission status: Accepted

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

ans = 0
if B > N:
    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:
    x=n
    ans=int(a*x/b)-a*(int(x/b))
    print(ans)
else:
    c=n//b
    x1=n
    x2=c*b-1
    ans1=(a*x1)//b-a*(x1//b)
    ans2=(a*x2)//b-a*(x2//b)
    print(max(ans1,ans2))

Submission status: Accepted

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    A,B,N = isRaw()
    
    if N<B:
        a1 = (A*N)//B
        return a1
    else:
        res = B-1
        a2 = (A*res)//B
        if A<=B:
            return max(a2,0)
        return max(a2, 0)
        
    
if __name__ == "__main__":
    print(main())

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

Submission status: Accepted

Solution code:
import sys
import math
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

res = n//b
x = b*res -1
if n < b:
    x = n

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

A, B, N = list(map(int, sys.stdin.buffer.readline().split()))

if N < 10:
    ans = 0
    for x in range(N + 1):
        y = A * x // B - A * (x // B)
        ans = max(ans, y)
    print(ans)
    exit()
if A == 1 or B == 1:
    print(0)
    exit()

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

# ans = 0
# for x in range(N + 1):
#     y = A * x // B - A * (x // B)
#     y2 = (A * (x % B) - (A * x % B)) / B
#     # print(x, y, y2)
#
#     z = x % B
#     print(z * A, (z * A) % B, (z * A - (z * A) % B) / B)
# print(ans)

Submission status: Accepted

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

if b <= n:
    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().strip().split())
t=0
if (b-1)<=n:
        t=(a*(b-1)//b)
else:
        t=(a*n)//b
    
   # t=max(t,((a*i)//b)-(a*(i//b)))
print(t)

Submission status: Accepted

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

q_b = a // b
r_b = a % b

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

q_ans = q_b * r + (r_b * r) // b

print(q_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:
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

A,B,N = LI()

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

Submission status: Accepted

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

x = math.floor(a*n/b)-( a*math.floor(n/b))
y = math.floor(a*b/b)-( a*math.floor(b/b))
z = math.floor(a*(b-1)/b)-( a*math.floor((b-1)/b))

if b == 1:
    print(0)
elif n < b:
    print(x)
else:
    print(z)

Submission status: Accepted

Solution code:
import numpy as np

def fLOOR(a,b,x):
    return np.floor(a * x / b) - a * np.floor(x / b)
"""
def fLOOR1(a,b,x):
    return np.floor(a * x / b)

def fLOOR2(a,b,x):
    return np.floor(x / b)
"""
def main():
    a,b,n = map(int, input().split(" "))
    
    """
    for x in range(n):
        x += 1
        val = fLOOR(a,b,x)
        val1 = fLOOR1(a,b,x)
        val2 = fLOOR2(a,b,x)
        print(val)
    """
    if b <= n:
        ans = fLOOR(a,b,b-1)
    else:
        ans = fLOOR(a,b,n)
    print(int(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

import math

ans=0
if N < B:
  end = N
else:
  end = B -1

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

Submission status: Accepted

Solution code:
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

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

print(max(f(n*B-1), f(N), 0) if n>0 else max(f(N),0))

Submission status: Accepted

Solution code:
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor

MOD = 10**9 + 7


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

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

Submission status: Accepted

Solution code:
import math

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

# if A % B == 0:
#     print(  min ( (A//B - 1) *B,A//B * N )

cands = []
temp = math.floor(A * N // B) - A * math.floor(N // B)
cands.append(temp)
if B <= N + 1 and B - 1 > 0:
    temp = math.floor(A * (B - 1) // B) - A * math.floor((B - 1) // B)
    cands.append(temp)
print(max(cands))

#
# cand = A * N //B
# cand2 = cand - 1
# ma = 0
# for x in range(1,N + 1):
#     temp = math.floor(A * x / B) - A * math.floor(x / B)
#     ma = max(temp,ma)
#     # print(math.floor(A * x / B),A * math.floor(x / B),x,temp)
# print(ma)

Submission status: Accepted

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

from math import floor

def f_ans(X):
  return floor(a*X/b) - a * floor(X/b)

temp = n // b
temp = temp * b
if b == 1:
  print(0)
elif temp > 0:
  print(f_ans(temp-1))
else:
  print(f_ans(n))

# for i in range(1,n+1):
#   print(str(i) + ':' + str(f_ans(i)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if n//b > 0:
  z = b-1
else:
  z = n

d = ((a*z)/b)//1
e = a*((z/b)//1)
y = d - e
v = math.floor(y)
print(v)

Submission status: Accepted

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

Submission status: Accepted

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

maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


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

Submission status: Accepted

Solution code:
from math import floor

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(int(f*int(A)))

Submission status: Accepted

Solution code:
import math

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

# for i in reversed(range(b)):
#     if i<=n:
#         print(math.floor(a*i/b))
#         break

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


a,b,n=map(int,input().split())
print(f(min(b-1,n)))

Submission status: Accepted

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

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


A, B, N = readnums()

'''

x = B - 1のとき最大？
f(A(B - 1) / B) = f(A - A/B)
A*f((B-1)/B) = 0

x = 2B - 1のとき
f(A(2B - 1) / B) = f(2A - A/B)
A*f((2B-1)/B) = A*f(2 - 1/B) = A

A <= Bのとき
x = B - 1のとき最大で、その値はA - 1

A > Bのとき
f(A - A/B) = A - A // B - 1
f(2A - A/B) - A = A - A//B - 1

'''

# test
# test = []
# N = random.randint(1, 10 ** 6)
# A = random.randint(1, 10 ** 6)
# B = random.randint(1, 10)
# print(A, B, N)
# for x in range(1, N + 1):
#     test.append(int(A * x / B) - A * int(x / B))

# print(max(test))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------


A, B, N = mii()

ans = 0
x = min(N, B)


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

if x > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)

Submission status: Accepted

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

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

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


res = f(n)


for i in range(max(1,n-10000),n+1):
    res = max(res,f(i))

w = (n//b)*b - 1
w2 = (n//b)*b - 1 + b

for i in range(max(1,w-10000),min(n+1,w+10000)):
    res = max(res,f(i))

for i in range(max(1,w2-10000),min(n+1,w2+10000)):
    res = max(res,f(i))


print(res)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
# from decimal import *
from fractions import *


def solve(A: int, B: int, N: int):
    def kansuu(x):
        # return math.floor(A*x/B) - A * math.floor(x/B)
        left = math.floor(Fraction(A) * Fraction(x) * Fraction(1, B))
        right = Fraction(A) * math.floor(Fraction(x, B))
        return left - right

    saidaibaisuu = (N // B) * B
    if saidaibaisuu == 0:
        print(kansuu(N))
        exit()
    else:
        print(kansuu(saidaibaisuu-1))
        exit()

    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:
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(A: int, B: int, N: int):
    print((A*min(N,(B-1))//B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
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()