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
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
A, B, N = map(int,input().split())



#N = min(N,A)

def test():
    mx = 0
    for x in range(1,B):
        v = (A*x)//B - A * (x//B)
        print (v)
        mx = max(mx,v)

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

Submission status: Accepted

Solution code:
import math
def floorm(a, b, n):
  ans = math.floor((a*n)/b) - a*(math.floor(n/b))
  return ans

  
a, b, n = map(int, input().split())
if(b>n):
  print(floorm(a, b, n))
else:
  print(floorm(a, b, b-1))

Submission status: Accepted

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

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

Submission status: Accepted

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


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

k = (n + 1) // b

x = max(k * b - 1, 0)
ans = f(x)
ans = max(ans, f(n))
print(ans)

Submission status: Accepted

Solution code:
a,b,n = map(int,input().split())
ans = 0
if b > n :
    x = n
    ans = (a*x)//b - a*(x//b)
elif b == n :
    x = n-1
    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:
import sys

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

a, b, n = get_ints()
if n>=b:
  x = b-1
else:
  x = n

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

x = min(b-1,n)

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

Submission status: Accepted

Solution code:
from math import floor
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A,B,N = map(int, readline().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))


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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


# 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
    print(solve(A, B, N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import sys
import re
import random
# import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

def lcm(a,b):
  return a // gcd(a,b) * b

## INPUT

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

def read_ints():
  # return map(int,raw_input().split())
  return [int(x) for x in input().split()]

def read_field():
  return input().rstrip()

def read_fields():
  return input().rstrip().split()

def solve(a,b,n):
    x=min(b-1, n)
    # print("x=%d" % x)
    u=a*x//b
    # print("u=%d" % u)
    return u

a,b,n = read_ints()
print(solve(a,b,n))

Submission status: Accepted

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

Submission status: Accepted

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

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:
#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,m = map(int,input().split())
best = min(b-1,m)

ans = a*(best/b)//1
print(int(ans))

Submission status: Accepted

Solution code:
import math
ABN = list(map(int,input().split()))

A = ABN[0]
B = ABN[1]
N = ABN[2]

    

if (N < B):
    max_value = int(math.floor(A*N/B))

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

Submission status: Accepted

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

from math import floor

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
if N < B:
    ans = math.floor(A * N / B)
elif N >= B:
    ans = math.floor(A * (B - 1) / B)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def input():
    return stdin.readline().strip()


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if B <= N:
    i = B - 1
    print(int(math.floor(A*i/B) - A * math.floor(i/B)))
else:
    i = N
    print(int(math.floor(A*i/B) - A * math.floor(i/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:
## coding: UTF-8
#import random
A, B, N = map(int,input().split())
'''
A = random.randint(1, 10**4)
B = random.randint(1, 10**4)
N = random.randint(1, 10**4)
#A, B, N = 1041, 6612, 695
#print('A:{}, B:{}, N:{}'.format(A, B, N))
'''
'''
maxi = -1
for x in range(1, N+1):
    p = int(A*x/B)
    m = A * int(x/B)
    #print('x:{}, p:{}, m:{}, p-m:{}'.format(x, p, m, p-m))
    if(p-m>maxi):
        maxi = p-m
        max_index = x
print(max_index)
print(maxi)
'''

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

p = int(A*x/B)
m = A * int(x/B)
ans = p-m
print(ans)

Submission status: Accepted

Solution code:
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

A,B,N = Ints()

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

ans = 0
n = 1
x = -(-(B*n)//A)

while x<=N and n <= A-1:
    ans = max(ans, (A*x)//B-A*(x//B))
    n += 1
    x = -(-(B*n)//A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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


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


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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
from math import gcd
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:
# -*- coding: utf-8 -*-
import math
a, b, n = map(int, input().split())
result = 0

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import floor
a,b,n = 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=[int(x) for x in input().split()]
# if n%b==0:
#     prev=n-1
# else:
#     prev=n
prev=min(b-1,n)
ans=math.floor((a*prev)/b)-a*math.floor(prev/b)
print(ans)

Submission status: Accepted

Solution code:
from math import floor


def calc(x):
    global a
    global b
    e1 = floor(a * x / b)
    e2 = a * floor(x / b)
    return e1 - e2


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

Submission status: Accepted

Solution code:
from math import floor

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

Submission status: Accepted

Solution code:
import numpy as np

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

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

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

Submission status: Accepted

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

def main():
    A, B, N = map(int, input().split())
    n = 1
    if(N < B):
        n = N
    else:
        n = B -1
    print(func(A, B, n))




main()

Submission status: Accepted

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

if(b > n):
	p = n
else:
	p = b - 1

ret = int(a*p/b) - a*int(p/b)
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
a,b,n=I()
ans=0
temp=min(n,b-1)
print(mt.floor((a*temp)/b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#


def main():
    a, b, n = map(int, input().split(" "))
    fac = 0
    start = min(b, n)
    if b <= n:
        fac = start - 1
    else:
        fac = start
    ans = a * fac // b - a * (fac // b)
    print(ans)


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

Solution code:
import math

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

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

print(v)

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

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:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

Solution code:
import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    if b>n:
        print(int(a*n/b)-a*int(n/b))
    else:
        print(int(a*(b-1)/b)-a*int((b-1)/b))
if __name__ == '__main__':
    do()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor

a, b, n = map(int, input().split())
num = min(n, b-1)
print(floor(a*num/b) - a * floor(num/b))

Submission status: Accepted

Solution code:
#D問題
import math
A,B,N = map(int, input().split())
result = 0
if(N <= B - 1):
    x = N
else:
    x = B - 1
print(math.floor(x * A / B ) - A * math.floor(x/B))

Submission status: Accepted

Solution code:
A, B, N = map(int, input().split())
l = -1
r = N
# ans = 0
# for i in range(1, N+1):
#     ans = max(ans, (A*i)//B - (A*(i//B)))
k = min(B-1, N)
ans2 = (A*k)//B - (A*(k//B))

print(ans2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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


if N < B:
    x = N
elif N == B:
    x = B - 1
elif N > B:
    x = B - 1


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import math
A,B,N = [int(x) for x in stdin.readline().rstrip().split()]
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=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,raw_input().strip().split()))
x=min(n,b-1)
ans=a*x//b
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b, n = list(map(int, input().split()))
if a == 1 or b == 1:
    print(0)
    exit()

if b <= n:
    k = n // b
    x = b * k - 1
else:
    x = n

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(main())

Submission status: Accepted

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

n = min(b,n) #search range
if n == b:
    n -= 1
ans = math.floor(a/b*n)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import math

i = B-1
#print(i, math.floor(a*i/b), a*math.floor(i/b), math.floor(a*i/b)-a*math.floor(i/b))

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

Submission status: Accepted

Solution code:
from math import floor

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

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

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

a,b,n=map(int,input().split())
# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr
# afac=factorization(a)
# bfac=factorization(b)
# print(afac,bfac)

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

Submission status: Accepted

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

c = 0

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

print(math.floor((a*c)/b))

Submission status: Accepted

Solution code:
import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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


def test():
    assert solve(5, 7, 4) == 2
    assert solve(11, 10, 9) == 9


if __name__ == "__main__":
    test()
    main()

Submission status: Accepted

Solution code:
# coding: utf-8


def run():
    A, B, N = map(int, input().split())
    if B-1 <= N:
        print(int(A*(B-1)/B))
    else:
        print(int(A*N/B))
if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, N = LI()

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

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

ans=-float("inf")
i=0

while True:
    x=b*i-1
    i+=1
    if x>n:
        ans=max(int((a*n)/b)-a*int(n/b), ans)
        print(ans)
        break
    if ans<int((a*x)/b)-a*int(x/b):
        ans=int((a*x)/b)-a*int(x/b)
    else:
        print(ans)
        break

Submission status: Accepted

Solution code:
import math

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


back = []


def backtrack(n, ml, mh, tmp=[]):
    if n == 0:
        back.append(tmp)
        return

    for i in range(ml, mh + 1):
        backtrack(n - 1, i, mh, tmp + [i])


def main():
    A, B, N = inpl()
    if B == 1:
        print(0)
        exit()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

a, b, n = map(int, input().split())
k = int((n+1) / b)

if n+1 < b:
  print(int(a*n / b) - a * int(n / b))
else:
  print(a - math.ceil(a / b))

Submission status: Accepted

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

if N >= B:
    x = B -1
else:
    x = N
MAX = 0
# for i in range(1,N+1):
#     MAX = max(MAX, (A*i)//B - A*(i//B))
# print(MAX)


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: n=b-1
print(math.floor((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:
# -*- coding: utf-8 -*-
a,b,n = map(int,input().split())
"""
ans = 0
tmp = min(b, n)
for x in range(int(pow(n, 0.5)) + 1, n+1):
    #print(x)
    tmp1 = (a * x) // b - (a * (x // b))
    if tmp1 >= ans:
        ans = tmp1
print(ans)
"""

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

Submission status: Accepted

Solution code:
import math


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


A, B, C = map(int, input().split())
# for i in range(2*B):
#     print(math.floor(A*i/B)-A*math.floor(i/B))
if C < B:
    print(GetScore(A, B, C))
else:
    print(GetScore(A, B, B-1))

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import floor


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

A, B, N = list(map(int, input().split()))
C = max(0, B*(N//B) - 1)
print(max(floor(A, B, N), floor(A, B, C)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

import math


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

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

    if n >= b:
        print(func(b - 1))
    else:
        print(func(n))

        
submit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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:
import math
a,b,n = map(int,input().split())
def cal(a,b,x):
  return((a*x)//b - a * (x//b))

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

Submission status: Accepted

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

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

    ans = -1
    for x in [N, B * (N // B) - 1]:
        if x >= 0:
            ans = max(ans, A * x // B - A * (x // B))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

i = min(b - 1,n)

print(math.floor(a*i*1.0/b)-a*math.floor(i*1.0/b))