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: Wrong Answer

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

Submission status: Wrong Answer

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
    
    if m<0:
        m += 1
    ans = floor(a*m/b)-a*floor(m/b)
print(ans)

Submission status: Wrong Answer

Solution code:
def main(n,m,q):
    l=[]
    for i in range(1,q+1):
        j=(n*i)//m-n*(i//m)
        l.append(j)
    sorted(l)
    print(l[-1])
n,m,q=map(int,input().split())
main(n,m,q)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
if n<b:
    max=math.floor(a*n/b)
else:
    #b<=n
    max=math.floor(a*b-1/b)
    for i in range(b,n+1):
        s2=math.floor(a*((1/b)-i//b))
        if max<s2:
            max=s2

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=(int(x) for x in input().split())
ans=0
for x in range(1,N+1):
    val=int(A*B*(x%B))
    if ans<val:
        ans=val
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	a,b,n = map(int,input().split())
	x = 0
	m = int((a*x)/b) - a* int(x/b)
	while x <= n:
		x += 1
		m = max( int((a*x)/b) - a* int(x/b), m)
	print(m)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(min(B-1, N))

Submission status: Wrong Answer

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

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

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

print(max(f(X),f(Y)))

Submission status: Wrong Answer

Solution code:
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
a,b,n=INPUT()
if n<=b:
    print(int(a*n/b))
else:
    print(int(a*(b-1)/b))

Submission status: Wrong Answer

Solution code:


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import math
 
a, b, n = (int(x) for x in input().split())
 
if n <= b :
    ans = math.floor(a * n / b) - a * math.floor(n / b)
else : 
    ans = math.floor(a * b / b) - a * math.floor(b / b)
 
print(ans)

Submission status: Wrong Answer

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a,b,n=n1()
import math
if b<=n:
    i=b-1
else:
    i=n
m=math.floor((a*i)/b)-a*math.floor(i//b)
print(i,m)

Submission status: Wrong Answer

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

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

if N >=  B:
    x = B
    z = (x % B) / B * A
else:
    x = N
    z = (x % B) / B * A

print(int(z))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split(" "))
ans = 0
x = B-1
floor1 = int(A*x/B)
floor2 = int(A*N/B) - A * int(N/B)
print(max(floor1,floor2))

Submission status: Wrong Answer

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

    #s2=math.floor(a*((1/b)-i//b))

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

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

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

# def numerical_diff(f, x):
#     """中央差分を元に数値微分する関数"""
#     h = 1e-4
#     return (f(x + h) - f(x - h)) / (2 * h)
#
# def gradient_descent(f, initial, learning_rate=1, steps=10):
#     """一階導関数から勾配法で最小値を求める関数"""
#     # 現在地を示すカーソル
#     x = initial
#
#     # 所定の回数を繰り返す
#     for _ in range(steps):
#         # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
#         grad = numerical_diff(f, x)
#         # 勾配を元にして現在地を移動する
#         x -= learning_rate * grad
#
#     # 最終的な位置を返す
#     return f(x)

ma = 0
for _ in range(int(1.7*10 ** 6)):
    ini = random.randrange(N + 1)
    # tmp = gradient_descent(f, ini)
    tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

if N >=  B:
    x = B
    z = (x % B) / B * A
else:
    x = N
    z = (x % B) / B * A

print(int(z))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x1 = N
x3 = B-1
if B-1>N:
    x3 =0
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
print(max(f(x1),f(x3)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

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

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

# def numerical_diff(f, x):
#     """中央差分を元に数値微分する関数"""
#     h = 1e-4
#     return (f(x + h) - f(x - h)) / (2 * h)
#
# def gradient_descent(f, initial, learning_rate=1, steps=10):
#     """一階導関数から勾配法で最小値を求める関数"""
#     # 現在地を示すカーソル
#     x = initial
#
#     # 所定の回数を繰り返す
#     for _ in range(steps):
#         # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
#         grad = numerical_diff(f, x)
#         # 勾配を元にして現在地を移動する
#         x -= learning_rate * grad
#
#     # 最終的な位置を返す
#     return f(x)

ma = 0
for _ in range(int(1.5*10 ** 6)):
    ini = random.randrange(N + 1)
    # tmp = gradient_descent(f, ini)
    tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

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

print(min(b, n))

Submission status: Wrong Answer

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()
x = N
ans = int((A*x)/B)-A*int(x/B)
if N >= B:
    n = int(N/B)
    n = B*n
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
    ans5 = int((A*(n))/B)-A*int((n)/B)
else:
    ans1 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans2 = ans
    ans3 = ans
    ans4 = ans
    ans5 = ans


print(max(ans, ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

Solution code:
a,b,n  = map(int, input().split())
#print(a,b,n)
#S=[]
N=[]
for s in range(1,n+1):
    #print((s*a)//b-a*(3//b))
    #S.append(s)
    N.append((s*a)//b-a*(3//b))
print(max(N))

Submission status: Wrong Answer

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

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append((int(a * (b - 1) / b) - a * (int((b - 1) / b))))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = -999999999
i, j = 0, n
while(i <= j):
    mid = i + (j - i) // 2
    if(((a * mid) // b) - a * (mid // n) >= x):
        i = mid + 1
        x = ((a * mid) // b) - a * (mid // n)
    else:
        j = mid - 1
    # print(i, j)    
print(x)

Submission status: Wrong Answer

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

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: Wrong Answer

Solution code:
import math
import random

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

def quick(x):
  pri = (A * x // B)
  lat = A * (x // B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(100000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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()
x = N
ans = int((A*x)/B)-A*int(x/B)
if N >= B:
    n = int(N/B)
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
    ans5 = int((A*(n))/B)-A*int((n)/B)
else:
    ans1 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans2 = ans
    ans3 = ans
    ans4 = ans
    ans5 = ans


print(max(ans, ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

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

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

if N > B:
    x = B
    z = (x % B) / B * A
else:
    x = N
    z = (x % B) / B * A

print(int(z))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import math

cnt = 0
box = [0]
floor = a*n//b - a*(n//b)
box.append(floor)
for x in reversed(range(1, n+1)):
  floor = a*x//b - a*(x//b)
  box.append(floor)
  cnt+=1
  if cnt > 1000:
    break
#  print(x, math.floor(a*x/b), a*math.floor(x/b), floor)

box.sort(reverse=True)
print(box[0])
#print(box)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
import math
s=[]
for x in range(N):
  t=math.floor(A*x/B)
  u=math.floor(x/B)
  v=t-A*u
  s.append(v)
w=max(s)
print(w)

Submission status: Wrong Answer

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

Score = list()
i = 1
while True:
  score = math.floor((A*i)/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    break
  i += 1
print(max(Score))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

cnt = 0
box = [0]
floor = a*n//b - a*(n//b)
box.append(floor)
for x in reversed(range(1, n+1)):
  floor = a*x//b - a*(x//b)
  box.append(floor)
  cnt+=1
  if cnt > 100:
    break
#  print(x, math.floor(a*x/b), a*math.floor(x/b), floor)

box.sort(reverse=True)
print(box[0])
#print(box)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(float,input().split())
if B==1 or A==1:
    ans = 0
else:
    while N%B==0:
        N = N-1
    ans = (A*N)//B - A*(N//B)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x1 = N
x3 = B-1
if B-1>N:
    x3 =0
def f(x):
    return math.floor((A*x)/B) - A * math.floor(x/B)
print(max(f(x1),f(x3)))

Submission status: Wrong Answer

Solution code:
import math

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

x = N//B - 1

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
D=int(A*B/math.gcd(A,B))
maxi=0
if B-1<=N:
  print((B-1)%B*A/B-(A*(B-1))%B/B)
else:
  print(N%B*A/B-(A*N)%B/B)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans_list = []
for x in range(N):
    ans_list.append(((A * x) // B) - (A * (x // B)))


print(max(ans_list))

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 0, -1):
        tmp = (A * i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Score = list()
i = 1
while True:
  score = math.floor(A*i/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    break
  i += 1
print(max(Score))

Submission status: Wrong Answer

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


##########
if __name__ == "__main__":
    d()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=0.1, max_loop=1000):
    #初期値を表示
    num_calc = 0  #計算回数
    #print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        #print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = int((x_max +x_min)/2.0)
        
        x_mid_max = int((x_max +x_mid)/2.0)
        x_mid_mim = int((x_min +x_mid)/2.0)
        
        #探索区間を更新
        if func_f(A,B,x_max) <= func_f(A,B,x_mid):
            x_mid = x_max
            break
        elif func_f(A,B,x_min) <= func_f(A,B,x_mid):
            x_mid = x_min
            break
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
        print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    if N >= B:
        solution = bisection(func_f, 0, B, A, B)
    else:
        solution = bisection(func_f, 0, N, A, B)
    print(-func_f(A,B,solution))

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt, floor

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


def I():
    return int(input())


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


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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

# 答えが最大になるｘ
if math.floor(N / B) > 0:
    ans_x = (N // B) * B - 1
else:
    ans_x = N

l = math.floor((A * ans_x) / B)
r = A * math.floor(ans_x / B)

ans = l - r

print(ans)

Submission status: Wrong Answer

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

Score = list()
i = 1
while True:
  score = math.floor(A*i/B) - A * math.floor(i/B)
  Score.append(score)
  if score <= max(Score):
    break
print(max(Score))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
#li = []
 
#for x in range(n+1):
ans = (math.floor((a*(n))/b) - (a * math.floor(n/b)))
if ans > n:
    print(n)
else:
    print(ans)

Submission status: Wrong Answer

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

ans = 0

if N < B:
    ans = int(((A*N)/B))
else:
    n = B//N
    f = 0
    for i in range(n):
        int(A*(N+B*i)/B)-A*(n-i)
        if f>= ans:
            ans = f

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import random
import decimal

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

decimal.getcontext().prec = 6
max = quick(decimal.Decimal(N))
for i in range(100000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(decimal.Decimal(ran))
  if(max < tem):
    max = tem

print(max)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
if B==1 or A==1:
    print(0)
elif N%B!=0:
    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: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
start=0
i=max(B-1,N)
K=math.floor(((i/B)-(i//B))*A)
if start<=K:
    start=K
print(start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = N//B

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


##########
if __name__ == "__main__":
    d()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

print(min(f(X),f(Y)))

Submission status: Wrong Answer

Solution code:
import math

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

c = 0
ans = -1
for i in range(1,n//b+1) :
    x = b*i-1
    if x > n :
        x = n
        c = 1
    if ans >= math.floor((a*x)/b)-a*math.floor(x/b) :
        break
    ans = math.floor((a*x)/b)-a*math.floor(x/b)
    if c == 1 :
        break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 1, -1):
        tmp = (A * i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=0.1, max_loop=1000):
    #初期値を表示
    num_calc = 0  #計算回数
    #print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        #print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = int((x_max +x_min)/2.0)
        
        x_mid_max = int((x_max +x_mid)/2.0)
        x_mid_mim = int((x_min +x_mid)/2.0)
        
        #探索区間を更新
        if func_f(A,B,x_max) <= func_f(A,B,x_mid):
            x_mid = x_max
            break
        elif func_f(A,B,x_min) <= func_f(A,B,x_mid):
            x_mid = x_min
            break
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
        print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    solution = bisection(func_f, 0, B, A, B)
    print(-func_f(A,B,solution))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

    if N < B:
        x = N
        res = math.floor(A * x / B)
        return print(res)

    x = (N // B) * B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    return print(res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def hoge(x, A, B):
    return int(A*x / B) - A * int(x / B)
A, B, N = map(int, input().split())
maxval = 0
for i in range(1, N + 1 if N < 10 else B + 1):
    res = hoge(i, A, B)

    if maxval < res:
        maxval = res

print(res)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
s=[ ]
import math
for x in range(N):
  s.append(math.floor((A*x)/B)-A*math.floor(x/B))
print(max(s))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x3 = B-1
if B-1>N:
    x3 =0
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)
print(max(f(x1),f(x3)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin
input = stdin.readline
def main():
  A,B,N=map(int,input().split())
  sMax=0
  if(N//B>=1):
    print(min(B-1,N))
  else:
    sMax=int(A*N/B)-A*int(N/B)
    print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

if N < B:
    ans = int(((A*N)/B))
else:
    n = B//N
    f = 0
    for i in range(n):
        int(A*(N-B*i)/B)-A*(n-i)
        if f>= ans:
            ans = f

print(ans)