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: Runtime Error

Solution code:
A, B, N= map(int, input().split())
score=[0]*(N+3)
for i in range(N):
    score[i]=(A*(i+1)//B)-((i+1)//B)
print(max(score))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
lst=[]
if n>=b:
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)

    print(max(ans,ans2,max(lst)))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print(max(ans,0))

Submission status: Runtime Error

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

fs = []
for x in range(N, 1, -1):
    fs.append((A * x) // B - A * (x // B))
    if len(fs) >= B:
        break
print(max(fs))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A, B, N = input().split()
A = float(A)
B = float(B)
N = float(N)
import math
value = math.floor(A*(B-1)/B)
max = 0
for i in range(B):
  a = int(math.floor(A*x/B)-A*math.floor(x/B))
  if a > max:
    max = a
if N < B-1:
  print(a)
else:
  print(value)

Submission status: Runtime Error

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

x = n//(b-1)
y = 0
for i in range(x+1):
    if i*(b-1) <= n:
        y = max(int(a*i*(b-1)/b) - a*int(i*(b-1)/b), y)
y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(0,N+1))
data2 = np.array(list(map(lambda x: A*math.floor(x/B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x/B), range_list)))

print(max(data1-data2))

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
a = []
C = N // B
 
if C = 0:
  for x in range(1,N+1):
  D = x/B
  Y = int(A*D)-A*int(D)
  a.append(Y)
else:
  for x in range((C-1)*B+1,N+1):
    D = x/B
    Y = int(A*D)-A*int(D)
    a.append(Y)

answer = max(a)
 
print(answer)

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
# xはN以下
# int(A*x/B) - A*int(x/B)の最大値を求めたい

# g(x)はBごとに数値が変わるので、Bで区切って計算すれば計算量を減らせる。
# その区間で、Bで割った余りがB-1、つまり最後の点が一番高い数値を出す。
# よって、計算量はN%B

# まずは区間を出す
compute_range = list(range(0, math.ceil(N / B)))
# print(compute_range)
# この区間の中で、二分探索する
# 01だと1の方が数値が大きいことがわかったら、次はその中で末尾を取る。
# ただし、範囲外にはならないように


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


max_num = 0
for i in range(B):
    index = compute_range[-1] * B + i
    if index > N:
        continue
    max_num = max(max_num, h(index))

print(max_num)

Submission status: Runtime Error

Solution code:
from math import floor

A, B, N = [int(n) for n in input().split()]
ans = []
for x in range(1, A):
    ans.append(int(floor(A*x/B)) - A*int(floor(x/B)))
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

if B > N :
    An =fl(N)
else :
    for i in range(1,N) :
        if i <= B :
            An = fl(N)
        elif i >= 2 and fl(i) < fl(i-1) :
            An = fl(i-1)
            break
        else:
            An = fl(N)


print(str(An))

Submission status: Runtime Error

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**2):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for _ in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= learning_rate * grad

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(N/2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp


print(ma)

Submission status: Runtime Error

Solution code:
import math
a, b, n = map(int, input().split())
score1 = math.floor(a*n/b) - a * math.floor(n/b)
for i in range(n, 0, -1):
    if math.floor((i+1)/b)-math.floor((i/b))>= 1:
        score2 = math.floor((a*i)/b) - a * math.floor(i/b)
        break
ans = max(score1, score2)
print(ans)

Submission status: Runtime Error

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

print(max([math.floor(a * i / b) - a * math.floor(i / b) for i in range(1, n + 1)]))

Submission status: Runtime Error

Solution code:

import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor(a*x/b)
s2=a*np.floor(x/b)
s=s1-s2
print(int(np.max(s)))

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N = map(int , input().split(" "))
nlist = np.array(list(range(N+1)))
floorlist = np.floor(A*nlist/B) - A * np.floor(nlist/ B)
#floorlist = int(A*nlist/B) - A * int(nlist/ B)
print(int(max(floorlist)))

Submission status: Runtime Error

Solution code:
import math


a, b, n = map(int, input().split())
li = []
x = n
while x > 0:
    an = math.floor(a*x/b) - a * math.floor(x/b)
    if an <= n:
        li.append(an)
    x -= 1
    if an <= max(li):
        print(max(li))
        break

Submission status: Runtime Error

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

import sys
import pprint
import math

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


main()

def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	if n < b:
		print(int((n/b - int(n/b))*a))
	else:
		print(int(((b-1)/b - int((b-1)/b))*a))

	


main()

Submission status: Runtime Error

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

def floor(x):
    return x//1

dp=[0]*(n+1)

for x in range(1,n+1):
    dp[x] = max(dp[x-1],floor(a*x/b)-a*floor(x/b))

print(int(dp[n]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	if B > x and B > A * x:
		continue
	elif B < x and B > A * x:
		continue
	elif B > x:
		t = int((A * x) / B) 
	else:
		t = int((A * x) / B) - A * int(x / B)
	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = list()
if n<=b:
  for i in range(n+1):
    y = int(a*i/b) - a*int(i/b)
    x.append(y)
else:
  for i in range(b):
    y = int(a*i/b) - a*int(i/b)
    x.append(y)
x = sort(x)
print(x[-1])

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
a = []
C = N // B
 
if C == 0:
  for x in range(1,N+1):
  C = x/B
  Y = int(A*C)-A*int(C)
  a.append(Y)
else:
  for x in range(C*B+1,N+1):
    C = x/B
    Y = int(A*C)-A*int(C)
    a.append(Y)
 
answer = max(a)
 
print(answer)

Submission status: Runtime Error

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

if B==1:
  print(0)

tb = B - 1
tp_pre = 0
while(True):
  tp = (A*tb)//B - A*(tb//B)
  if tp > tp_pre:
    tp_pre = tp
  tb += B
  if tb > N:
    break

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

Submission status: Runtime Error

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

x = n//(b-1)
y = 0
for i in range(x+1):
    if i*(b-1) <= x:
        y = max(int(a*i*(b-1)/b) - a*int(i*(b-1)/b), y)
y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Runtime Error

Solution code:
import math

A,B,N=map(int,input().split())
ans=[0]*N
for x in range(0,N+1):
    a=math.floor(A*x/B)
    b=A*math.floor((x/B))
    ans[x-1]+=a-b
print(max(ans))

Submission status: Runtime Error

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

if C = 0:
  for x in range(1,N+1):
  C = x/B
  Y = int(A*C)-A*int(C)
  a.append(Y)
else:
  for x in range(C*B+1,N+1):
    C = x/B
    Y = int(A*C)-A*int(C)
    a.append(Y)
 
answer = max(a)
 
print(answer)

Submission status: Runtime Error

Solution code:
import math

A,B,N=map(int,input().split())
list=[]
t=0
if B > N:
    print(math.floor(A*N/B))
else:
    for x in range(B+1,N):
        if t==0:
            y=math.floor(A*x/B)-A*math.floor(x/B)
        else:
            z=math.floor(A*x/B)-A*math.floor(x/B)
            if y - z>0:
                y = z
            else:
                break

    print(y)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

def check():
    x = np.arange(1, N+1)
    tmp = np.floor(A * (x/B) ) - (A * np.floor(x / B))
    #ans = math.floor((A * x)/B) - (A*math.floor(x/b))
    print(int(max(tmp)))


def solve():
    ans = 0
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
#solve()
check()

Submission status: Runtime Error

Solution code:
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(1,N+1))
data2 = np.array(list(map(lambda x: A*math.floor(x/B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x/B), range_list)))

print(max(data1-data2))

Submission status: Runtime Error

Solution code:
a, b , n= map(int, input().split())
prev=int(a*n/b)-a*int(n/b)
for i in range(n-1,0,-1):
  now=int(a*i/b)-a*int(i/b)
  if now<=prev:
    now=prev
    break
  prev=now
print(now)

Submission status: Runtime Error

Solution code:
from math import floor
A, B , N = map(int, input().split())
List = [0,0]
for x in range(N+1):
    Answer = floor((A*x)/B) - (A*floor(x/B))
    List.append(Answer)
    List.pop(List[0])
# print(List)
print(max(List))

Submission status: Runtime Error

Solution code:

import numpy as np
a,b,n=map(int,input().split())

x=np.arange(1,n+1)

s1=np.floor((a/b)*x)
s2=a*np.floor(x/b)
s=s1-s2
print(int(np.max(s)))

Submission status: Runtime Error

Solution code:
import math


a, b, n = map(int, input().split())
li = []
x = n
while x > 0:
    an = math.floor(a*x/b) - a * math.floor(x/b)
    if an <= n:
        li.append(an)
    x -= 1
    if an <= max(li):
        print(max(li))
        exit()

Submission status: Runtime Error

Solution code:
import math
A,B,N = map(int,input().split())
x=list(range(1,N+1))
MAX=[]

for i in x:
    ans = math.floor(A*i/B)-A*math.floor(i/B)
    MAX.append(ans)

print(max(MAX))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
N = int(input())
print(int(A*(N-1)/B)-A*int((N-1)/B))

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
ans=[0]*b
if c>b-2:
    for i in range(b):
        d=(i+1)*b-1
        ans[i]=int((a*d)/b)-a*(int(d/b))
        if c<d:
            break
else :
    for i in range(c):
        ans[i]=int((a*i)/b)-a*(int(i/b))
print(max(ans))

Submission status: Runtime Error

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

for i in reversed(range(1,n+1)):
    if i/b < 1:
        res = floor(a*i/b) - a * floor(i/b)
        break

print(res)

Submission status: Runtime Error

Solution code:
A, B, N = [int(n) for n in input().split()]
ans = []
for x in range(1, A):
    ans.append(int(A*x/B) - A*int(x/B))
print(max(ans))

Submission status: Runtime Error

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

x=np.arange(1,n+1)

s1=np.floor((a/b)*x)
s2=a*np.floor(x/b)
s=s1-s2
print(np.max(s))

Submission status: Runtime Error

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

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


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
x = np.arange(min(N, B-1), N+1, B)
x = func(x)

# 結果出力
print(int(np.max(x)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = n//(b-1)
y = 0
for i in range(x):
    if i*(b-1) <= x:
        y = max(int(a*i*(b-1)/b) - a*int(i*(b-1)/b), y)
y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Runtime Error

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

for i in range(n+1):
    if i%b==0:
        continue
    k = int(a*i/b)-a*int(i/b)
    lis.append(k)
    
print(max(lis))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b , n= map(int, input().split())
prev=int(a*n/b)-a*int(n/b)
for i in range(n-1,0,-1):
  now=int(a*i/b)-a*int(i/b)
  if now<=prev:
    now=prev
    break
print(now)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(1,N))
data2 = np.array(list(map(lambda x: A*math.floor(x / B), range_list)))
data1 = np.array(list(map(lambda x: math.floor(A*x / B), range_list)))

print(max(data1-data2))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
import matplotlib.pyplot as plt
func = []
A , B , N = map(int , input().split())
for x in range(N+1):
    func.append(math.floor((A*x) / B ) - A * math.floor(x / B )) 
    if x != 0:
        if func[x] > func[x-1]:
            break
print(max(func))

Submission status: Runtime Error

Solution code:
def main():
    a,b,n = map(int,input().split())
    aa = min(b,n)
    for i in range(aa,n):

        ans = max(ans,a*aa//b  - a * (aa//b))
    print(ans)
if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
maxn =0
if A<B:
    if B/2 <N:
        t = math.ceil(B/2)-1
        ans = tmp = math.floor((A*t)/B)-A*(math.floor(t/B))
    else:
        ans = tmp = math.floor((A*N)/B)-A*(math.floor(N/B))
else:
    for x in range(1,B+1):
        tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
        if maxn < tmp:
            maxn = tmp
    ans =maxn
print(ans)

Submission status: Runtime Error

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

for i in range(n,1,-1):
    if a*math.floor(i/b)<math.floor(a*i/b):
        ans=math.floor(a*i/b)-a*math.floor(i/b)
        break

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	if B > x and B > A * x:
		t = int((A * x) / B)
	if B > A * x:
		continue
	else:
		t = int((A * x) / B) - A * int(x / B)
	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

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

 cal = int((A*N)/B) - A*int(N/B)
 print(cal)

Submission status: Runtime Error

Solution code:
import math

A,B,N=map(int,input().split())
ans=[0]*N
for x in range(0,N+1):
    a=math.floor(((A*x)/B))
    b=A*math.floor((x/B))
    ans[x-1]+=a-b
print(max(ans))

Submission status: Runtime Error

Solution code:
def main():
    A, B, N = map(int, input().split(" "))
    max_score = -float("inf")

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

number = list(range(min(b, n+1)))
current = b*2
while current-1 <= n:
    number.append(current-1)
    current += b

max_v = 0
for x in number:
    v = math.floor(a*x/b) - a * math.floor(x/b)
    max_v = max(v, max_v)

print(max_v)

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(2*(10**9)) 
a, b, n =map(int,input().split())
x = 0
ans = [0]*(n+1)
for x in range(n+1) :
     ans[x] =  math.floor(a*x/b) - a*(math.floor(x/b))
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

def check():
    x = np.arange(1, N+1)
    tmp = np.floor((A * x)/B ) - (A * np.floor(x / B))
    #ans = math.floor((A * x)/B) - (A*math.floor(x/b))
    print(int(max(tmp)))


def solve():
    ans = 0
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
#solve()
check()

Submission status: Runtime Error

Solution code:
a, b , n= map(int, input().split())
prev=int(a*n/b)-a*int(n/b)
for i in range(n-1,0,-1):
  now=int(a*i/b)-a*int(i/b)
  if now<prev:
    now=prev
    break
print(now)

Submission status: Runtime Error

Solution code:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    
    if n > 10 ** 5:
        for x in range(n, math.sqrt(n), -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass
    else: 
        for x in range(n, 0, -1):
            fx = math.floor(a * x / b) - math.floor(x / b) * a
            #print(fx)
            if ans < fx:
                ans = fx
            if ans > fx + 10 ** 3:
                #exit()
                pass

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
al2 = []
for i in range(n,-1,-1):
    ans = ((a*i)//b)-(a*(i//b))
    al.append(ans)
    al2.append((a*i)/b)-(a*(i/b))
    if len(al2) > 1:
        if al2[-1] <= al2[-2]:
            break
if max(al) < 0:
    print(0)
else:
    print(max(al))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N = map(int , input().split(" "))
nlist = np.array(list(range(N+1)))
floorlist = np.floor(A*nlist/B) - A * np.floor(nlist/ B)
print(int(np.max(floorlist)))

Submission status: Runtime Error

Solution code:
import math

A = int(input(" "))
B = int(input(" "))
N = int(input(" "))

Ma = -100;
for i in range(N+1):
    Ma = max(Ma,math.floor(A*i/B) - A*math.floor(i/B))

print(Ma)

Submission status: Runtime Error

Solution code:
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

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

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

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, min(N+1)):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
A=0
C=b[1]
max = b[2]//b[1]

for i in range(max+1):
    A=b[1]-1
    if A>0:
        check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
        if check > ans:
            ans=check
    b[1]+=b[1]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

dp=[0]*(n+1)

for x in range(n):
    dp[x+1] = max(dp[x],((a*(x+1)/b)//1)-a*(((x+1)/b)//1))

print(int(dp[n]))

Submission status: Runtime Error

Solution code:
import numpy as np

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

l = np.zeros(N)

for i in range(1,N+1):
    l[i-1] = np.floor((A*i)/B) - A * np.floor(i/B)

print(int(np.max(l)))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
s=n//b
nmax = (a*n)//b - a*(n//b)
# for i in range(1,s+1):
#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
# b_n = b
# b_nn = 0
# while b_n <= n:
#     x = b_n -1
#     t = (a*x)//b - a*b_nn
#     if t > nmax:
#         nmax = t
#     b_n += b
#     b_nn +=1
x = b*s-1
t = (a*x)//b - a*b_nn
if t > nmax:
    nmax = t
print(nmax)

Submission status: Runtime Error

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

for x in reversed(range(N+1)):
        ans=math.floor(A*x/B)-(A*math.floor(x/B))
        if ans >= max_ans:
            max_ans=ans
print(max_ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
ans=[0]*b
if c>b-2:
    for i in range(b):
        d=(i+1)*b-1
        ans[i]=int((a*d)/b)-d*(int(d/b))
        if c<d:
            break
else :
    ans[0]=int((a*c)/b)-b*(int(c/b))
print(max(ans))

Submission status: Runtime Error

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

for i in reversed(range(1,n+1)):
    if floor(i/b) == 0:
        res = floor(a*i/b) - a * floor(i/b)
        break
print(res)

Submission status: Runtime Error

Solution code:
import math

a, b, n = map(int, input().split())
box = [0] * (n + 1)

for i in range(n + 1):
    box[i] = math.floor((a * i) / b) - a * math.floor(i / b)

print(max(box))

Submission status: Runtime Error

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

#print(A)
#print(B)
#print(N)

#xs = [math.floor(A * i / B) - (A * math.floor(i / B)) for i in range(1, N+1)]
#print(max(xs))

ret = 0
ra = []
for i in reversed(range(1, N+1)):
  #print("i = ")
  #print(i)
  temp = math.floor(A * i / B) - (A * math.floor(i / B))
  if temp > 0 and temp in ra:
    break;
  #print(temp)
  if temp > ret:
    ret = temp
    ra.append(ret)

#print("結果")
#print(ret)
print(max(ra))

Submission status: Runtime Error

Solution code:
(defun calc (x a b n)
  (- (floor (/ (* a x) b))
     (* a (floor (/ x b)))))

(let ((a (read))
      (b (read))
      (n (read)))
     (format t "~A" (if (<= b n)
                        (calc (1- b) a b n)
                        (calc n a b n))))

Submission status: Runtime Error

Solution code:
a,b,n = map(int,input().split())
ans = 0
ans = max(int(a*n/b) - a*int(n/b),ans)
for k in range(1,n//(b-1)+1):
    ans = max(int(a*(k*b-1)/b) - a*int((k*b-1)/b),ans)
    if ans == a:
        print(ans)
        break
if ans != a:
    print(ans)

Submission status: Runtime Error

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

if a<b:
    ans=(a*n//b)-a*(n//b)
    
else:
    if :a%b==0:
        ans=(a*x//b)-a*(x//b)
    else:
        ans=(a*n//b)-a*(n//b)

print(ans)

Submission status: Runtime Error

Solution code:
A,B,N = list(map(int,input().split()))
Ans = []
for i in range(1,B-1):
    if i <= N:
        a = ((A*i)/B)//1 - A * ((i/B)//1)
        Ans.append(a)
i = 1
while True:
    x = B*i - 1
    if x <= N:
        a = ((A*x)/B)//1 - A * ((x/B)//1)
        Ans.append(a)
        if Ans[-1] < Ans[-2]:
            break
        i += 1
    else:
        break
print(int(max(Ans)))

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ApB = A / B

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	if B > x:
		t = int(ApB * x)
	else:
		t = int(ApB * x) - A * int(x/B)
	if (t > ans):
		ans = t

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

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

    max=0
    # for x in range(N+1):
    #     # ans=int(A*x/B)-A*int(x/B)
    #     min,_=math.modf(x/B)
    #     # ans=int(A*min)
    #     # print(min)
    #     if x==0:
    #         max=min
    #     elif min > max:
    #         max=min
    #     else:
    #         break

    max=0
    max_x=0
    reg=[False]*B

    for x in range(N+1):
        rem = x%B
        if reg[rem]:
            break
        else:
            reg[rem]=True
        if rem > max:
            max=rem
            max_x=x

    # min,_=math.modf(max_x/B)

    print(int(A*max_x/B)-A*int(max_x/B))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

tmp = 0
for x in (range(1, b+1, b-1) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc

print(tmp)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append
siki = int((a*(x))/b) - a * int(x/b)
for x in range(n+1):
    append(siki)
print(max(li))

Submission status: Runtime Error

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0
if b>10**6:
	print(a*n//b-a*n//b)

else:
	for i in range(a):
	cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	print(cnt)

Submission status: Runtime Error

Solution code:
import math
a,b,c = map(int,input().split())
ans = [0]*c
for x in range(c, 0, int(-1)):
    ans[x-1] = math.floor(a*x/b) -  math.floor(a* math.floor(x/b))
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
a, b, n = map(int, input().split())
score1 = 0
socre2 = 0
score1 = math.floor(a*n/b) - a * math.floor(n/b)
for i in range(n, 0, -1):
    if math.floor((i+1)/b)-math.floor((i/b))>= 1:
        score2 = math.floor(a*i/b) - a * math.floor(i/b)
        break
ans = max(score1, score2)
print(ans)

Submission status: Runtime Error

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

tmp = 0
for x in (range(1, b+1, b-1) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    #calc = (a*x)//b - a*(x//b)
    
    if calc > tmp:
        tmp = calc

print(tmp)

Submission status: Runtime Error

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

l = []
for x in range(N+1):
    Z = (A * x) // B - A * (x // B)
    l += Z
print(max(l))

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
A = A//G
invA = mod_inv(A,B)
if 1:   
    InvList = []
    for i in range(A):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        if x < 0:continue
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

Solution code:
# D

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

alpha, beta = math.floor(A/B), A%B
if B-1 < N:
    x = B-1
else:
    x = N
    
print(math.floor(A*x/B) - A * math.floor(x/B))

Submission status: Runtime Error

Solution code:
import math
A,B,N = map(int, input().split())  
ANS=[0]*(N)
k=1
for i in range(N):
  ANS[i]=math.floor(A*k/B)-A*math.floor(k/B)
  k+=1
ANS.sort()
print(ANS[-1])