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: Time Limit Exceeded

Solution code:
import sys
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)

max = 0
for x in range(1, B + 1):
    if x > N:
        break
    fx = f(x)
    # print(fx)
    if fx > max:
        max = fx
print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
x = N
a = 0
while x>999*N//1000:
  if x%B != 0 and a < A*x//B - A*(x//B):
    a = A*x//B - A*(x//B)
    x -= 1
  else:
    x -= 1
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
x = N
a = 0
while x>9*N//10:
  if x%B != 0 and a < A*x//B - A*(x//B):
    a = A*x//B - A*(x//B)
    x -= 1
  else:
    x -= 1
print(a)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
x = N
a = 0
while x>N//2:
  if x%B != 0 and a < A*x//B - A*(x//B):
    a = A*x//B - A*(x//B)
    x -= 1
  else:
    x -= 1
print(a)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
x = 0
a = 0
while x<=N:
  if x%B != 0 and a < A*x//B - A*(x//B):
    a = A*x//B - A*(x//B)
    x += 1
  else:
    x += 1
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    tmp = (a*i+a)//b - (i+1)//b * a
    ans = max(ans, tmp)

print(ans)

Submission status: Time Limit Exceeded

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


def main() -> None:
    A, B, N = rmi()
    X = N if N % B != 0 else N - 1
    max_score = 0
    for x in range(X, max(X - B, 0), -1):
        score = (A * x) // B - A * (x // B)
        max_score = max(max_score, score)
    w(max_score)


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10**9)
    main()

Submission status: Time Limit Exceeded

Solution code:
a, b, n = [int(e) for e in input().split()]

ans = 0

for i in range(1,min(b+1,n+1)):
    ans = max(int(a*i/b)-a*int(i/b),ans)

print(ans)

Submission status: Time Limit Exceeded

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

max = 0
for i in range(1, n + 1):
    tmp = ((a * i) // b) - (a * (i // b))
    max = tmp if tmp > max else max

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
c1,c2,c3 = (int(x) for x in input().split())
c5 =int(0) 
for i in range(int(c3/10),c3 + 1):
    c4 = math.floor(c1*i/c2) - c1*math.floor(i/c2)
    if c5 <=c4:
        c5 = c4
print(c5)

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
c1,c2,c3 = (int(x) for x in input().split())
c5 =int(0) 
for i in range(int(c3/100),c3 + 1):
    c4 = math.floor(c1*i/c2) - c1*math.floor(i/c2)
    if c5 <=c4:
        c5 = c4
print(c5)

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
c1,c2,c3 = (int(x) for x in input().split())
c5 =int(0) 
for i in range(1,c3 + 1):
    c4 = math.floor(c1*i/c2) - c1*math.floor(i/c2)
    if c5 <=c4:
        c5 = c4
print(c5)

Submission status: Time Limit Exceeded

Solution code:
import math as m

i = list(map(int, input().split()))
max = 0

def calc(x):
    return m.floor(i[0]*x/i[1]) - i[0]*m.floor(x/i[1])

for k in range(1, i[2] + 1):
    if (max < calc(k)):
        max = calc(k)

print(max)

Submission status: Time Limit Exceeded

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

beta = 0.0e0
for ni in range( n+1 ):
#    print( ni )
    betai = ni/b  - int( ni/b )
    beta = max( beta, betai )

ans = int( a * beta )
print( ans )

Submission status: Time Limit Exceeded

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

ans = int( 0 )
for ni in range( n+1 ):
#    print( ni )
    ansi = int( ( a*ni )/b ) - a * int( ni/b )
    ans = max( ans, ansi )

print( ans )

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
point = 0
ans = 0
for x in range(0,N+1):
    #print(math.floor(A*x/B)-A*math.floor(x/B))
    #print(point)
    #print("p")
    if point<math.floor(A*x/B)-A*math.floor(x/B):
        point = math.floor(A*x/B)-A*math.floor(x/B)
print(point)

Submission status: Time Limit Exceeded

Solution code:
import math

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

max = 0
for i in range(N+1):
    value = math.floor(A*i/B) - A*math.floor(i/B)
    if value > max:
        max=value
print(max)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = [int(e) for e in input().split()]

ans = 0

for i in range(int(b/a),n+1):
    ans = max(int(a*i/b)-a*int(i/b),ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = [int(e) for e in input().split()]

ans = 0

for i in range(n+1):
    ans = max(int(a*i/b)-a*int(i/b),ans)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(1, N+1):
    j = int(A*i/B)-A*int(i/B)
    if j > ans:
        ans = j
print(ans)

Submission status: Time Limit Exceeded

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

    max1 = 0
    k1 = math.ceil(B/A)
    k2 = B+1 if B<N else N+1
    for x in range(k1,k2):
        tmp = int(A*x/B) - A*int(x/B)
        max1 = max(max1,tmp)
    print(max1)

main()

Submission status: Time Limit Exceeded

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

    max1 = 0
    k = math.ceil(B/A)
    for x in range(k,N+1):
        tmp = int(A*x/B) - A*int(x/B)
        max1 = max(max1,tmp)
    print(max1)

main()

Submission status: Time Limit Exceeded

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

    max1 = 0
    for x in range(1,N+1):
        tmp = int(A*x/B) - A*int(x/B)
        max1 = max(max1,tmp)
    print(max1)

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
res=int((a*1.0)/b)-a*int(1.0/b)
for x in range(2,n+1):
  res2=int((a*x*1.0)/b)-a*int(x*1.0/b)
  if res2>res:
    res=res2
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int,input().split())
val_list =[]
flag = False
for x in range(1,n+1):
    val = math.floor(a*x/b)-a*math.floor(x/b)
    val_list.append(val)
    if flag == True:
        if val_list[x-2]>val_list[x-1]:
            break
    else:
        flag = True
        pass
print(max(val_list))

Submission status: Time Limit Exceeded

Solution code:
import math
nums = [int(e) for e in input().split()]
d = []
for i in range(0,nums[2]+1):
    a = math.floor(nums[0]*i/nums[1]) - nums[0] * math.floor(i/nums[1])
    d.append(a)
print(max(d))

Submission status: Time Limit Exceeded

Solution code:
import math

nums = [int(e) for e in input().split()]

d = []
for i in range(0,nums[2]+1):
    a = math.floor(nums[0]*i/nums[1]) - nums[0] * math.floor(i/nums[1])
    d.append(a)

print(max(d))

Submission status: Time Limit Exceeded

Solution code:
import math

nums = [int(e) for e in input().split()]

d = []
for i in range(0,nums[2]+1):
    d0 = []
    a = math.floor(nums[0]*i/nums[1]) - nums[0] * math.floor(i/nums[1])
    d0.append(a)
    d.append(max(d0))

print(max(d))

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n = map(int,input().split())
val_list =[]
for x in range(1,n+1):
    val = math.floor(a*x/b)-a*math.floor(x/b)
    val_list.append(val)
print(max(val_list))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys


def solve(A: int, B: int, N: int):
    def f(x: int) -> int:
        return int(A*x/B) - A*int(x/B)
    print(max(map(f, range(min(B, N)+1))))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

maxVal = 0

for i in range(b):
    if i > n:
        break
    val = math.floor(a*i/b)-a*math.floor(i/b)
    if val > maxVal:
        maxVal = val

print(maxVal)

Submission status: Time Limit Exceeded

Solution code:
import math

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

x = 1
max_floor = 0
while x <= N:
    if x >= B:
        break
    else:
        max_floor = max(math.floor(A * x / B), max_floor)
    x += 1
print(max_floor)

Submission status: Time Limit Exceeded

Solution code:
import math

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

x = 1
max_floor = 0
while x <= N:
    if x >= B:
        break
    if (A / B * x) >= 1:
        max_floor = max(math.floor(A * x / B) - A * math.floor(x / B), max_floor)
    x += 1
print(max_floor)

Submission status: Time Limit Exceeded

Solution code:
import math

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

x = 1
max_floor = 0
while x <= N:
    max_floor = max(math.floor(A * x / B) - A * math.floor(x / B), max_floor)
    if x >= B:
        break
    x += 1
print(max_floor)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
c_0 = 0
m = min(n+1, b)
for x in range(1, m):
  if x % b == 0:
    c = 0
  else:
    c = int(a * x / b)
    if c >= c_0:
      c_0 = c
print(c_0)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
c_0 = 0
m = min(n, b) + 1
for x in range(1, m):
  if x % b == 0:
    c = 0
  else:
    c = int(a * x / b)
    if c >= c_0:
      c_0 = c
print(c_0)

Submission status: Time Limit Exceeded

Solution code:
import math

data = input().split(' ')

A = int(data[0])
B = int(data[1])
N = int(data[2])

max = 0


while N != 0:

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

    if max < num:

        max = num

    N -= 1

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

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

m = 0
for i in range(1, n + 1):
    m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)

Submission status: Time Limit Exceeded

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N+1))), default=N)
    # print('max_x:', max_x)
    return max(maxM, calcM(A, B, max_x))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Time Limit Exceeded

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v2(A, B, N)
    print(M)

Submission status: Time Limit Exceeded

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = 0
    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calc(A, B, x))
    return maxM


if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v1(A, B, N)
    print(M)

Submission status: Time Limit Exceeded

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

# def resolve_v2(A, B, N):
#     if B < N:
#         return max(calcM(A, B, N+1), calcM(A, B, N))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v1(A, B, N)
    print(M)

Submission status: Time Limit Exceeded

Solution code:
import math

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

a=N//B

ans_list=[]

if a==0:
    x=N
    ans_list.append(math.floor(A*x/B)-A*math.floor(x/B))
    
else:
    for i in range(a+1):
        x=B*i-1
        ans_list.append(math.floor(A*x/B)-A*math.floor(x/B))
    ans_list.append(math.floor(A*N/B)-A*math.floor(N/B))

ans=max(ans_list)

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_score = 0
y = b // a

for x in range(max(y - 10000000, 1) , min(y + 20000000, n+1)):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Time Limit Exceeded

Solution code:
import math


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


A, B, n = map(int, input().split())
start, end = 0, n

maximum = 0
for i in range(n + 1):
    value = eq_value(A, B, i)
    if value > maximum:
        maximum = value

print(maximum)

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split())
ans = 0
for i in range(1, n+1):
    chk = math.floor((a*i)/b) - a*math.floor(i/b)
    if ans < chk:
        ans = chk
    else:
        pass
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(1 , n+1):
    ans_p = (a*i//b) - a * (i//b)
    if ans_p >= ans:
        ans = ans_p

print(ans)

Submission status: Time Limit Exceeded

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

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

max = 0
for i in range(N//2, N + 1):
    if(floor(i) > max):
        max = floor(i)


print(max)

Submission status: Time Limit Exceeded

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

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

max = 0
for i in range(N + 1):
    if(floor(i) > max):
        max = floor(i)


print(max)

Submission status: Time Limit Exceeded

Solution code:
a, b, c = map(int, input().split())
M=int(a/b)-a*(int(1/b))
for i in range(2,c+1):
  d=int(a*i/b)-a*(int(i/b))
  if d>M:
    M=d
print(M)

Submission status: Time Limit Exceeded

Solution code:
a, b, c = map(int, input().split())
M=(a/b)//1-a*((1/b)//1)
for i in range(2,c+1):
  d=(a*i/b)//1-a*((i/b)//1)
  if d>M:
    M=d
print(int(M))

Submission status: Time Limit Exceeded

Solution code:
a, b, c = map(int, input().split())
M=0
for i in range(c+1):
  d=(a*i/b)//1-a*((i/b)//1)
  if d>M:
    M=d
print(int(M))

Submission status: Time Limit Exceeded

Solution code:
a, b, c = map(int, input().split())
def floor(a,b,c):
  M=0
  for i in range(c+1):
    d=(a*i/b)//1-a*((i/b)//1)
    if d>M:
      M=d
  return int(M)
print(floor(a,b,c))

Submission status: Time Limit Exceeded

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

ans = 0
lenge = min(b-1, n)
for x in range(lenge+1):
    y = int((a*x)/b) - a * int(x/b)
    ans = max(y, ans)

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
lenge = min(b-1, n)
for x in range(lenge+1):
    y = math.floor((a*x)/b) - a * math.floor(x/b)
    ans = max(y, ans)

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(n+1):
    y = math.floor((a*x)/b) - a * math.floor(x/b)
    ans = max(y, ans)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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

    num = N//B

    score = 0
    for x in range(1, N+1):
        tmp = int(A*x/B) - A*int(x/B)
        if score <= tmp:
            score = tmp
    print(score)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = -float("inf")
for x in range(n):
    #print(a*((x+1)%b)//b)
    if a*((x+1)%b)//b > ans:
        ans = a*((x+1)%b)//b

#print("----------")
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
max_n = -1
endpoint = min(B-1,N)
for i in range(endpoint+1) :
    n = ((A * i) // B) - A * (i // B)
    # print(i,n)
    if (max_n < n) :
        max_n = n

print(max_n)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
max = 0
for x in range(1,n+1):
    m = math.floor(a*x/b) - a * math.floor(x/b)
    if max < m:
        max = m
        
print(max)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = list(map(int, input().split()))
fnc = lambda x: int(a*x/b) - a*int(x/b)
prev = 0
for i in range(n+1):
    now = fnc(i)
    if prev > now:
        print(prev)
        break
    elif i == n:
        print(now)
        break
    prev = now

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
A,B,N=map(int, input().split())
NUM=0
if N<B:
    NUM=math.floor(A*N/B)-A*math.floor(N/B)
    print(NUM)
    sys.exit()
else:
    if A>B:
        for x in range(N+1,math.floor(N/4),-1):
            TGT=math.floor(A*x/B)-A*math.floor(x/B)
            if TGT>NUM:
                NUM=TGT
    else:
        for x in range(1,math.floor(N/4)+1):
            TGT=math.floor(A*x/B)-A*math.floor(x/B)
            if TGT>NUM:
                NUM=TGT
print(NUM)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = (map(int , input().split()))
max_ = 0
for x in range(1,N+1):
    max_ = max(max_,((A*x)//B - A * (x//B)))
print(max_)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
A,B,N=map(int, input().split())
NUM=0
if N<B:
    NUM=math.floor(A*N/B)-A*math.floor(N/B)
    print(NUM)
    sys.exit()
else:
    if A>B:
        for x in range(N+1,math.floor(N/2),-1):
            TGT=math.floor(A*x/B)-A*math.floor(x/B)
            if TGT>NUM:
                NUM=TGT
    else:
        for x in range(1,math.floor(N/2)+1):
            TGT=math.floor(A*x/B)-A*math.floor(x/B)
            if TGT>NUM:
                NUM=TGT
print(NUM)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
A,B,N=map(int, input().split())
NUM=0
if N<B:
    NUM=math.floor(A*N/B)-A*math.floor(N/B)
    print(NUM)
    sys.exit()
for x in range(1,N+1):
    TGT=math.floor(A*x/B)-A*math.floor(x/B)
    if TGT>NUM:
        NUM=TGT
print(NUM)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N=map(int, input().split())
NUM=0
for x in range(1,N+1):
    TGT=math.floor(A*x/B)-A*math.floor(x/B)
    if TGT>NUM:
        NUM=TGT
print(NUM)

Submission status: Time Limit Exceeded

Solution code:
import time

def floor(y):
    return int(y)

def main():
    a, b, n = map(int, input().split())
    ans = [floor(a*x/b) - a*floor(x/b) for x in range(1, n+1)]
    print(max(ans))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

ans = [math.floor(a*x/b) - a*math.floor(x/b) for x in range(1, n+1)]

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
l=-10
for i in range(n+1):
  d=a*i//b-a*(i//b)
  if d>l:
    l=d
print(l)

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int, input().split())
com = 0
if n < b:
    x = n
else:
    x = b-1
while x >= 0:
    val = (a*x)//b-a*(x//b)
    if val < com:
        pass
    else:
        com = val
    x -= 1
print(com)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N=map(int,input().split())
M=0
for i in range(N+1):
  C=math.floor(A*i/B)-A*math.floor(i/B)
  if M<C:
    M=C
print(M)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
a,b,n = map(int, input().split())
x = n
com = 0
while x >= 0:
    val = (a*x)//b-a*(x//b)
    if val < com:
        pass
    else:
        com = val
    x-=1
print(com)

Submission status: Time Limit Exceeded

Solution code:
from math import floor
a,b,n = map(int, input().split())
x = n
com = 0
while x >= 0:
    val = floor((a*x)/b)-a*floor(x/b)
    if val < com:
        pass
    else:
        com = val
    x-=1
print(com)

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b+1):
        tmp = math.floor((a*x)/b) - a*math.floor(x/b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = 0
for x in range(1, min(B-1, N)+1):
    now = (A*(x%B) - (A*x)%B)/B
    ans = max(now, ans)
print(int(ans))

Submission status: Time Limit Exceeded

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

def floor(t):
    return t // 1

ma = 0
x = 0
a_b = A/B

while True:
    if x > N: break
    a = floor(a_b*x) - A * floor(x/B)
    x += 1
    if a > ma:
        ma = a

print(int(ma))

Submission status: Time Limit Exceeded

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

def floor(t):
    return t // 1

ma = 0
x = 0
while True:
    if x > N: break
    a = floor(A*x/B) - A * floor(x/B)
    x += 1
    if a > ma:
        ma = a

print(int(ma))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
    now = (A*(x%B) - (A*x)%B)/B
    ans = max(now, ans)
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
    now = (A*x)//B - A*(x//B)
    ans = max(now, ans)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(10 ** 7):
  print(A * i // B - A * (i // B))
  ans = max(ans, A * i // B - A * (i // B))

for i in range(10 ** 7):
  i = N - i
  if i < 0:
    break
  ans = max(ans, A * i // B - A * (i // B))

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(10 ** 8):
  print(A * i // B - A * (i // B))
  ans = max(ans, A * i // B - A * (i // B))

for i in range(10 ** 8):
  i = N - i
  if i < 0:
    break
  ans = max(ans, A * i // B - A * (i // B))

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import time

A,B,N = map(int,input().split())
max_n = -1
st = time.time()
for i in range(N+1) :
    # n = math.floor((A * i)/B) - A * math.floor(i/B)
    # n = ((A * i) // B) - A * (i // B)
    n = ((A * i) // B) - A * (i // B)
    # print(i,n)
    if (max_n < n) :
        max_n = n
    
    if (time.time() - st > 2) :
        break

print(max_n)

Submission status: Time Limit Exceeded

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

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

ans = 0
for x in range(1, min(b+1, n+1)):
    ans_tmp = math.floor(a*x/b) - a * math.floor(x/b)
    ans = max(ans, ans_tmp)
print(ans)

Submission status: Time Limit Exceeded

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

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

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

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


print(ans)

Submission status: Time Limit Exceeded

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

a, b, n = map(int, readline().split())
t = 0
max_t = 0

for i in range(n, 1, -1):
    t = math.floor(a*i/b) - a * math.floor(i/b)
    if t > max_t:
        max_t = t

print(max_t)

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

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

ans =0

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

print(ans)