Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Accepted

Solution code:
def floor(x):
    return int(x)

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

    X = B-1 if B-1 <= N else N
    X = float(X)

    ans = floor(A*X/B) - A*floor(X/B)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,n=map(int,input().split())
if n>=b-1:
    count=0
    for i in range(a):
        count+=(((b-1)/b)+(i/a))//1
    print(int(count))
else:
    count=0
    for j in range(a):
        count+=((n/b)+(j/a))//1
    print(int(count))

Submission status: Accepted

Solution code:
import sys
import math

if __name__ == '__main__':
    a, b, n = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    old = 0
    if 0 <= b-1 and b-1 <= n:
        x = b - 1
        print(math.floor(a*x/b)-a*math.floor(x/b))
    else:
        x = n
        print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Accepted

Solution code:
import math
data = input().rstrip().split(" ")
ap = int(data[0])
bp = int(data[1])
max = int(data[2])
one = 0
two = 0
answer = 0
if bp - 1 <= max:
    change = bp - 1
else:
    change = max

one = math.floor(ap * change / bp)
two = math.floor(change / bp)
answer = one - two * ap
print(answer)

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
# Problem D - Floor Function

import math

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

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

# output
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a, b, n = [int(x) for x in input().split()]
    # gen = (a * x // b - x // b * a for x in range(min(b, n) + 1))

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

    return a * x // b - x // b * a


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

Submission status: Accepted

Solution code:
import math
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(N))
    exit()
    
ans = []
for i in range(B-100,B+100):
    ans.append(func(i))
    
print(max(ans))

Submission status: Accepted

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

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:
    N = B
print(max(f(N),f(N-1)))

Submission status: Accepted

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

if (b == 1) or (a == 1):
    temp = 0


if (b <= n):
    temp = a * (b - 1) / float(b)
#  ans = math.floor(temp)
else:
    temp = (a * n) / float(b)
   # ans =

ans = math.floor(temp)
print(ans)

Submission status: Accepted

Solution code:
import math

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

solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B <= N:
        x = B-1
    else:
        x = N

if not solved_flag:
    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())
a=min(N,B-1)
print(A*a//B)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,n = map(int, input().split())
if n >= b:
  print((a*(b-1))//b - 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())
Max = 0
if b != 1:
    x = min(n, b-1)
    while x <= n:
        Max = max(math.floor(a*x/b) - a * math.floor(x/b),Max)
        x += b
else:
    Max = 0
print(Max)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N >= B:
    N = B - 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    A, B, N = map(int, read().split())
    m = N % B
    x1 = N
    x2 = N - m - 1
    if x2 > 0:
        ans = max((A * x1) // B - A * (x1 // B), (A * x2) // B - A * (x2 // B))
    else:
        ans = (A * x1) // B - A * (x1 // B)
    print(ans)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = s[0]
b = s[1]
n = s[2]
x = 0
if b-1 <= n:
    x = b-1
    ans = math.floor(a*x/b)-n*math.floor(x/b)
else:
    x = n
    ans = math.floor(a*x/b)-n*math.floor(x/b)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a,b,x = map(int, input().split())
point = 0
if x < b:
    print(int(a*x/b)-(a*int(x/b)))
else:
    for i in range(b-100, b+100):
        point = max(int(a*i/b)-(a*int(i/b)), point)
    print(point)
# for i in range(1,x+1):
#     print(int(a*i/b),a*int(i/b),int(a*i/b)-(a*int(i/b)))

Submission status: Accepted

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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))


print(max(dammy))

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

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

    ans = 0

    if N >= B:
        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:
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
lrs = lambda: [_ for _ in rs().split()]
lri = lambda: [int(_) for _ in rs().split()]
lrf = lambda: [float(_) for _ in rs().split()]

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

Submission status: Accepted

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


def solve(A: int, B: int, N: int):
    if N < B - 1:
        x = N
        print(int(A * x / B))
    else:
        x = B - 1
        print(int(A * x / B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
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())
x = b - 1
if b > n:
    x = n
else:
    x = b - 1
print((a*x) // b - a * (x//b))

Submission status: Accepted

Solution code:
a,b,n=list(map(int,input().split()))
ans=0
#for x in range(n+1):
if b==n:
  x=n-1
else:
  x=b-1 if n-1>=b else n
ans=int(a*x/b)-a*int(x/b)
print(ans)
#print(x,int(a*x/b),int(x/b)*a,ans)

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

def f(x):
    return a * x // b - a * (x // b)
if b - 1 <= n:
    print(f(b - 1))

else:
    print(f(n))

Submission status: Accepted

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

# val = (int(A * i / B) - A * int(i / B) for i in range(1, N+1))
# print(max(val))

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

Submission status: Accepted

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


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

    if n < b:
        return (a * n) // b

    if n < b * 2:
        return ((a * ((b * 2) - 1)) // b) - a

    return 0


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

A,B,N = inpl()
if B <= N:
  x = B-1
else:
  x = N
    
print(A*x//B)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def calc_floor(A, B, X):
    return (int(A * X / B) - A * int(X / B))

A, B, N = map(int, sys.stdin.readline().split())
if N >= B - 1:
    print(calc_floor(A, B, B - 1))
else:
    print(calc_floor(A, B, 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:
a, b, n = map(int, input().split())
ans = 0
if n >= b:
    ans = int(a * (b - 1) / b) - a * int((b - 1) / b)
else:
    ans = int(a * n / b) - a * int(n / b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    f = lambda x: int(A*x/B) - A * int(x / B)

    if B == 1:
        print(0)
    else:
        ans = 0
        x = B * (N // B) - 1 if N >= B else N
        ans = max(f(x), ans)
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

max_v = 0
for x in range(-1, min(B, N+1), min(B, N+1)):
    if x <= 0:
        continue
    v = math.floor(A*x/B) - A*math.floor(x/B)
    if max_v < v:
        max_v = v
print(max_v)

Submission status: Accepted

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

if b == 1:
    ans = 0
else:
    ans = (a * min(n, (b - 1)) / b) // 1 - a * ((min(n, (b - 1)) / b) // 1)

print(int(ans))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

a, b, n = map(int, input().split())
if b == 1:
    print(0)
    sys.exit(0)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, N = map(int,input().split())
fivex = 0
i = 1
ans = 0
x = 0
# ans_x = -((-1)*A*N // B)
# if ans_x>N:
#     ans_x -= 1
# print(ans_x)
# print(int(A*ans_x/B)-A*int(ans_x/B))
while x <= B:
    x = -((-1)*i*B // A)
    if x > N:
        break
    now = i - A *  int(x / B)
    if now > ans and x <= N:
        # print(x)
        ans = now
    i += 1

print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import math


A, B, N = MAP()


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


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

Submission status: Accepted

Solution code:
import math

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

m = 0
n = 1

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

while n<N:
  c = B*(math.floor((n+1)/B)+1)-1
  n = min(N, c)
  m = max(cal(n), m)
  if (A*n)%B == 0:
    break
  
print(m)

Submission status: Accepted

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

a,b,n = (int(x) for x in input().split())
c = min(b-1,n)
print(math.floor(a*(c/b)))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#intの場合
  
A, B ,N  = map(int,input().split())

if N > B - 1 and A <= B:
  print (A-1)
elif A > B  and N >= B - 1 :
  N = B - 1
  y = math.floor( A * N /B) - A * math.floor( N / B)
  print(y )
# A < B < N
else :
  y = math.floor( A * N /B) - A * math.floor( N / B)
  print(y )

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math
a, b, n = map(int, input().split())
if n >= b:
    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:


A, B, N = [int(x) for x in input().split()]
best = (A * (min(N, B - 1) % B)) // B
print(best)

Submission status: Accepted

Solution code:
# coding: utf-8

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

if N >= b-1:
    i = b-1
    ans = (a*i) // b - a * (i // b)
else:
    i = N
ans = (a*i) // b - a * (i // b)
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

else:
    if N % B == 0:
        x = B-1
    else:
        x = B-1

ans = math.modf((x/B))[0]*A
print(int(ans))

Submission status: Accepted

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

if A == 1:
    print(0)
    exit()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

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

Submission status: Accepted

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

def floor(A,B,x):
    num=int(A*x/B)
    return num

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

f1=floor(a,b,x)
f2=a*floor(1,b,x)
print(f1-f2)

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split())
r = min(n, b - 1)
upper = a
lower = 0
while upper - lower > 1:
  x = int((upper + lower) / 2)
  if x * b <= a * r:
    lower = x
  else:
    upper = x
print(lower)

Submission status: Accepted

Solution code:
import math

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

max_value = 0
x = B - 1
if x > N:
    x = N
max_value = math.floor(A * x / B) - A * math.floor(x / B)
# for x in range(1, N+1):
#     value = math.floor(A * x / B) - A * math.floor(x / B)
#     print("X:", x, "value:", value)
#     max_value = max(max_value, value)

print(max_value)

Submission status: Accepted

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

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

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

  print(ans)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, n = _ia()
    return (a * min(b-1, n))//b

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# D - Floor Function

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

# max(floor(a * x / b) - a * floor(x / b) for 0 <= x <= n)
# x = k * b のとき, 第1項 == 第2項
# k * b <= x < (k+1) * b のとき, 第1項は単調増加, 第2項は一定

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

Submission status: Accepted

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

def floor(x,y):
  return int(x/y)

if b > n:
  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())
Z=0
if N<B:
    Z=(A*N)//B

else:
    Z=(A*(B-1))//B

print(Z)

Submission status: Accepted

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


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

import sys
import math

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

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

def main():
    a, b, n = read_list(int)
    if n < b:
        print(f(n, a, b))
        return
    print(f(b - 1, a, b))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

c = N // B

ans = 0

if c != 0:
    ans = int(A*(B-1)/B)
else:
    ans = int(A * N / B)

print(ans)

Submission status: Accepted

Solution code:


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # floor(Ax/B)-A*floor(x/B)
    # floor(A(kB+p)/B)-A*floor((kB+p)/B)= Ak+floor(Ap/B)-A*(k+floor(p/B))=
    # = floor(Ap/B)
    # x = kB+p, p<B, X<=N
    # p = min(B-1, N)
    # A(B-1)/B
    A, B, N = read_ints()
    p = min(B-1, N)
    return A*p//B


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

Submission status: Accepted

Solution code:
import math

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

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

print(_max)

Submission status: Accepted

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

if n<b:
	res=f(a,b,n)
	print(res)
else:
	res=f(a,b,b-1)
	if n%b==0:
		res=max(res,f(a,b,n-1))
		print(res)
	else:
		res=max(res,f(a,b,(n//b)-1))
		print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


x = 2

def hantei(x,a,b):
    rr = 0
    rr = int(a*x//b) - a * int(x//b)
    return rr



mx = n//b
ans = 0
ans_n = hantei(n,a,b)
ans_0 = hantei(0,a,b)

if(mx == 0):
    x = n
    ans = hantei(x,a,b)
else:
    flag = 1
    x = 2*b - 1
    ans = max(ans,hantei(x,a,b))
    #print(ans)

asn = max(ans,ans_n,ans_0)    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

print(ans)