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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

print(int(f))

Submission status: Accepted

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


A, B, N = map(int, input().split(" "))
if B <= N:
    print(f(A, B, B - 1))
else:
    print(f(A, B, N))

Submission status: Accepted

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

if n < b-1:
    print(func(n))
else :
    print(func(b-1))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = floor(min(b-1,n))

print(int(ans))

Submission status: Accepted

Solution code:
A,B,N=map(int,input().split())
b=B-1
ans=(A*(N))//B-A*((N)//B)
while b<=N:
    num=(A*b)//B-A*(b//B)
    if ans>=num:
        break
    else:
        ans=num
    b+=B
print(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 = list(map(int, input().split()))
x = min(b - 1, n) # b-1がいいけど、上限 nの制約あり
ans = int(a * x / b)
print(ans)

Submission status: Accepted

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

ans = f(min(n,b-1))
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def f(x: int) -> int:
    """目的関数

    Arguments:
        x {int} -- 非負整数

    Returns:
        int -- 目的関数値
    """
    return math.floor(A*x/B) - A*math.floor(x/B)


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    f(x+B) = f(x)より、0 <= x <= (B-1)についてのみ考える.
    このとき、f(x) = floor(Ax/B)であり、これはxについての単調増加関数である.
    よって、求める最大値はf(min(B-1, N))である.
    """
    result = f(min(B-1, N))

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

ans = f(min(n,b-1))
print(ans)

Submission status: Accepted

Solution code:
import math

def input_number():
    return int(input())

def input_1line_list(number_of_input):
    return [input() for i in range(number_of_input)]

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

# def print_unique_length(input_list):
#     print(len(set(input_list)))

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

def main():
    a, b, n = input_1line()
    x = min(b-1, n)
    ans = f(a, b, x)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

def floor_t(A,B,y):
    return math.floor(A*y/B) - A*math.floor(y/B)

#関数の挙動を調べる
# for x in range(1,10*B+1):
#     print('x={} : floor(AX/B)={}'.format(x,math.floor(A*x/B)))

# for x in range(1,10*B+1):
#     print('x={} : floor(X/B)={}'.format(x,A*math.floor(x/B)))

# for i in range(1,10*B+1):
#     print('x={}:f(x)={}'.format(i,floor_t(A,B,i)))

X=min(N,B-1)

print(floor_t(A,B,X))

Submission status: Accepted

Solution code:
import math


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

x = min(N, B-1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# sys.stdin = open('input.txt')


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

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

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

Submission status: Accepted

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

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

ans = f(N)
if B - 1 <= N:
    D = (N // B) * B
    ans = max(ans, f(D - 1))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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());print(a*min(n,b-1)//b)

Submission status: Accepted

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

x = min(N, B - 1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Nlist = list(map(int, input().split()))

A = Nlist[0]; B = Nlist[1]; N = Nlist[2]

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

Submission status: Accepted

Solution code:
from math import floor

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

Submission status: Accepted

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

Submission status: Accepted

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


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

x = min(b - 1, n)
ans = f(x)
print(ans)

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,n = map(int, raw_input().split(' '))
m = 0
print min(b-1,n) * a /b
"""
for t in range(0, min(b,n) + 1):
	print t*a/b
	m = max(m,t * a / b)
	#print int(t * a / b)
print m
"""

Submission status: Accepted

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

A, B, N = In.ints()

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

Out.int(res)
        
######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


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:
A,B,N = map(int, input().split())
if B == 1 or A == 1:
  floor = 0
else:
  if N < B:
    floor = int(A*N/B) - A*int(N/B)
  elif N == B:
    floor = int(A*(N-1)/B) - A*int((N-1)/B)
  else:
    floor = max([(int(A*(x-1)/B) - A*int((x-1)/B)) for x in range(B,N,B)])
    
print(floor)

Submission status: Accepted

Solution code:
import math

n = list(map(int,input().split()))
x = min(n[1]-1 , n[2])
if n[2] >= n[2]:
    print(math.floor(n[0] * x / n[1]))

Submission status: Accepted

Solution code:
[A,B,N] = list(map(int,input().split()))
 
X = N
Y = min(B-1,N)
 
out1 = A*X//B - A*(X//B)
out2 = A*Y//B - A*(Y//B)
print(max(out1,out2))

Submission status: Accepted

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

X = N
Y = min(B-1,N)

out1 = int(A*X/B) - A*int(X/B)
out2 = int(A*Y/B) - A*int(Y/B)
print(out2)

Submission status: Accepted

Solution code:

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

A, B, N = m()

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())
x = min(N, 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)
if c % B == 0:
    print(int(A*(c-1)/B))
else :
    print(int(A*(c)/B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor

def main():
    A,B,N=map(int,input().split())
    
    ans1=min(N,B-1)
    ans2=floor(A*ans1/B)-A*floor(ans1/B)
    print(ans2)
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
from pprint import pprint

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

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

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

Submission status: Accepted

Solution code:
import sys
import math
from pprint import pprint

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

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

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

Submission status: Accepted

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

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

print(num)

Submission status: Accepted

Solution code:
import sys
import math
from pprint import pprint
 
A, B, N = map(int, sys.stdin.readline().strip().split())
 
def func(x):
    return A*x//B - A*(x//B)
 
 
right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    if mid_left == mid_right:
        break
    # print("func", func(mid_left), func(mid_right))
    if func(mid_left) <= func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)
 
ans = -1 * float("inf")
for i in range(left, right+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from pprint import pprint

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

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


right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    #if mid_left == mid_right:
    #    break
    # print("func", func(mid_left), func(mid_right))
    if func(mid_left) <= func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)

ans = -1 * float("inf")
for i in range(left, right+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
 
ans1 = ((A*N)//B)-A*int(N/B)
 
if B-1<=N:
	ans2 = (A*(B-1))//B
else:
  	ans2=0
 
print(max(ans1,ans2))

Submission status: Accepted

Solution code:
from sys import stdin
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
 
ans1 = (A*N)//B-A*(N//B)
 
if B-1<=N:
	ans2 = (A*(B-1))//B
else:
  	ans2=0
 
print(max(ans1,ans2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  a = 0
  ans = (A*a)//B - A*math.floor(a/B)
else:
  ans = (A*a)//B - A*math.floor(a/B)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


print(f(min(n, b-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

if A*N < B:
    print(0)
    exit()

if N < B:
    print((A*N)//B - A*(N//B))
    exit()

aa = N//B
x = aa*B - 1
res = (A*x)//B - A*(x//B)

print(res)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
ans2=0
if B-1<N:
	ans = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
    
 
 
print(ans)

Submission status: Accepted

Solution code:
a, b, n = map(int, input().split()) 
if b == 1 or a == 1: 
    print(0) 
else: 
    r = min(b-1, n) 
    s = (a * r) // b - a * (r // b)    
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    A, B, N = map(int, readline().rstrip().split())
    x = min(B-1, N)
    ans = (A * x) // B - A * (x // B)
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(8*(10**6)):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(5*(10**6)):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math
def main():
    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)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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


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


print(f(min(n, b-1)))

Submission status: Accepted

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

a=min(B,N)

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

else:
    m = n//b
    m = m*b-1
    ans = a*m//b-a*floor(m/b)
print(ans)

Submission status: Accepted

Solution code:
A, B, N = list(map(int, input().split()))
def function(a, b, x):
  return (a*x)//b - a*(x//b)
print(max([function(A, B, N), function(A, B, max([1, N-N%B-1]))]))

Submission status: Accepted

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

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

else:
    m = int(n//b)
    m = m*b-1
    ans = (a*m)//b-a*(m//b)
print(ans)

Submission status: Accepted

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

ans = int( a*(x/b - 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)

print(f(min(b-1, n)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

if A == 1 or B == 1:
    print(0)
    sys.exit()

i = 0
x = 0
mx = 0

while(x < min(A*B, N)):
    pt = (A * x) // B - A * (x // B)
    mx = max(mx, pt)
    i += 1
    x = i * (B-1)
    
last = (A * N) // B - A * (N // B)
mx = max(mx, last)
print(mx)

Submission status: Accepted

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


# S = input()
# X1_list = [int(input()) for i in range(N)]
# X2_list = [list(map(int,input().split())) for i in range(N)]
def solve(i):
    a = int(A * i / B)
    b = A * int(i / B)
    return a - b


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

Submission status: Accepted

Solution code:
import sys,bisect,string,math,time,functools,random
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            a,b,c=(inp+[1])[:3]
            org_inp.append(inp)
        else:
            index=0
            a,b,c=(ls[i]+[1])[:3]
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)];rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

class Tree:
    def __init__(self,inp_size=None,init=True):
        if init:
            self.stdin(inp_size)
        return

    def stdin(self,inp_size=None):
        if inp_size==None:
            self.size=int(input())
        else:
            self.size=inp_size
        self.edges,_=GI(self.size,self.size-1)
        return
    
    def listin(self,ls):
        self.size=len(ls)+1
        self.edges,_=GI(self.size,self.size-1,ls)
        return

    def __str__(self):
        return  str(self.edges)

    def dfs(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append(x)
        v=[-1]*self.size
        v[x]=root_v
        while q:
            c=q.pop()
            for nb,d in self.edges[c]:
                if v[nb]==-1:
                    q.append(nb)
                    v[nb]=func(v[c],nb,d)
        return v

    def EulerTour(self,x,func=lambda prv,nx,dist:prv+dist,root_v=0):
        q=deque()
        q.append((-1,x))
        v=[None]*self.size
        v[x]=root_v
        et=[]
        while q:
            cb,ce=q.pop()
            et.append(ce)
            for nb,d in self.edges[ce]:
                if v[nb]==None:
                    q.append((nb,ce))
                    q.append((ce,nb))
                    v[nb]=func(v[ce],nb,d)
        vid=[[-1,-1]for i in range(self.size)]
        for i,j in enumerate(et):
            if vid[j][0]==-1:
                vid[j][0]=i
            else:
                vid[j][1]=i
        return v,et,vid
    
    def LCA_init(self,depth,et):
        self.st=SegTree(self.size*2-1,func=min,ide=inf)
        for i,j in enumerate(et):
            self.st.update(i,j)
        self.LCA_init_stat==True
        return
    
    def LCA(self,root,x,y):
        if self.LCA_init_stat==False:
            depth,et,vid=self.EulerTour(root)
            self.LCA_init(depth,et)
        return self.st.query(x,y+1)

show_flg=False
show_flg=True

ans=0

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

Submission status: Accepted

Solution code:
# D - Floor Function
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:
import math
A,B,N = list(map(int, input().split()))

x = min(N, B-1)

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()

    p = min(b-1,n)
    #print(p)
    print(floor(a*p/b) - a*floor(p/b))


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3pip
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] = list(map(int, input().split()))
if N < B-1:
    print(A * N // B)
else:
    print(A * (B-1) // B)

Submission status: Accepted

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

x = min(b - 1, n)

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

Submission status: Accepted

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

x = min(b - 1, n)

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

Submission status: Accepted

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

x = min(b - 1, n)

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

Submission status: Accepted

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    a, b, n = wi()
    if n >= b-1:
        print(floor(a*(b-1), b) - a*floor((b-1), b))
    else:
        print(floor(a*n, b) - a*floor(n, b))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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