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 math

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

    ans = 0

    for x in range(1, N+1):
        tmp_ans = math.floor(A * x / B) - A * math.floor(x / B)
        if ans <= tmp_ans:
            ans = tmp_ans

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import pprint
import math

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

s = min(n, b)
max_num = 0
for x in range(s + 1):
    tmp = math.floor(a * x / b) - a * math.floor(x / b)
    max_num = max(max_num, tmp)

print(max_num)

Submission status: Time Limit Exceeded

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

if B>N:
  print(A*N//B)
  exit()
list=0
for i in range((2*N//3),N+1):
  if i>B:
    list=A*i//B
  else:
    c=((A*i)//B)-(A*(i//B))
    if list<c:
      list=c
print(list)

Submission status: Time Limit Exceeded

Solution code:
num = input()
num = num.split(' ')

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

import math

anslist = []
for x in range(N + 1):
  ans = math.floor(A*x/B) - A * math.floor(x/B)
  anslist.append(ans)
  
print(max(anslist))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 0
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts += 1
		if maxs < tmp:
			maxs = tmp
		if conts == 100000000:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = input().split()
max = 0

for x in range(int(N) +1):
    if max < (math.floor(int(A) * x / int(B)) - int(A) * math.floor(x / int(B))):
        max = (math.floor(int(A) * x / int(B)) - int(A) * math.floor(x / int(B)))
        #print(max, x)

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_num = -1
tmp = 0
for x in range(n+1):
  tmp = a * x / b // 1 - a * (x / b // 1)
  if max_num <= tmp:
    max_num = tmp
  else:
    break

if (max_num == -1):
  max_num = tmp
  
print(int(max_num))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans = -1
if(n > 10**6 and a % b == 0):
    for x in range(b-1,n+1,b):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in range(n + 1):
    fl_1 = a * x / b // 1
    fl_2 = a * (x/b // 1)
    ans = fl_1 - fl_2
    L.append(ans)
    # print(x)
    # print(fl_1)
    # print(fl_2)
    # print(L)
    # print()

print(int(max(L)))

Submission status: Time Limit Exceeded

Solution code:
a, b,n = list(map(int, input().split()))
res = 0
for x in range(1, n+1):
    if  a *(x//b) != 0:
        break
    if res < (a*x)//b - a *(x//b):
        res = (a*x)//b - a *(x//b)

print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
from sys import stdin


def get_result(data):
    A, B, N = data
    x = [B*(i+1)-1 for i in range(N//B+1)]
    ans = []
    for val in x:
        if val > N:
            val = N
        ans.append(math.floor(A*val/B) - A*math.floor(val/B))
    return max(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)

Submission status: Time Limit Exceeded

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

if B>N:
  print(A*N//B)
  exit()
list=0
for i in range((N//2),N+1):
  if i>B:
    list=A*i//B
  else:
    c=((A*i)//B)-(A*(i//B))
    if list<c:
      list=c
print(list)

Submission status: Time Limit Exceeded

Solution code:
import math

def readInt():
	return int(input())
 
def readInts():
	return list(map(int, input().split()))
 
def readChars():
	return input().split()

a,b,n = readInts()
res = -1000

for x in range(min(b,n)+1):
	y = (a*x)//b-a*(x//b)
	#print(y)
	if y>res:
		res = y

print(res)

Submission status: Time Limit Exceeded

Solution code:

import math

val = input()

a = int(val.split(" ")[0])
b = int(val.split(" ")[1])
n = int(val.split(" ")[2])

#print(a, b, n)

max = 0

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

print(max)

Submission status: Time Limit Exceeded

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

ans.sort(reverse=True)
print(ans[0])

Submission status: Time Limit Exceeded

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

for x in range(int(n), int(n/2), -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    # print(n)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0
    if n > 10 ** 10:
        for x in range(n, 10 ** 8, -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

    elif n > 10 ** 8:
        for x in range(n, 10**6 , -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

    elif n > 10 ** 6:
        for x in range(n, 10**4 , -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: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		if maxs < tmp:
			maxs = tmp

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

x = 0
for i in range(N+1):
    D = math.floor(x/B)
    if D != 0:
        break
    x += 1
print(math.floor(A*(x-1)/B)-math.floor((x-1)/B)*A)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
p = input().split()
k =[int(s) for s in p]
a = k[0]
b = k[1]
n = k[2]
t = []
for i in range(1,n+1):
    c = (a*i)//b
    d = (i//b)*a
    e = c - d
    t.append(e)
print(max(t))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = 0

for x in reversed(range(max(1,n-b),n+1)):
    if m > (a*x) // b:
        break
    else:
        y = (a*x)//b - a * (x//b)
        if m < y:
            m = y

print(m)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a, b ,n = map(int, input().split())
mx = 0
 
def floor(a, b, x):
    return(int(a*x/b) - a * int(x/b))

for i in range(n):
    y = floor(a, b, i + 1)
    if mx <= y:
        mx = y

print(mx)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
from sys import stdin


def get_result(data):
    A, B, N = data
    x = [B*(i+1)-1 for i in range(N//B+1)]
    ans = []
    for val in x:
        if val > N:
            val = N
        ans.append(math.floor(A*val/B) - A * math.floor(val/B))
    return max(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def solve(A: int, B: int, N: int):
    print(max([math.floor(A*x/B) - A*math.floor(x/B) for x in range(1, min(B+1, N+1))]))
    return


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:
li=list(map(int,input().split()))
a=li[0]
b=li[1]
n=li[2]
def floor(t):
    return(int(t))
li=[]
ans=floor(a*0/b)-a*floor(0/b)
for x in range(n+1):
    s=floor(a*x/b)-a*floor(x/b)
    if s>ans:
        ans=s
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

box = []

for num in range(N+1):
    X = math.floor(A*num/B) - A * math.floor(num/B)
    box.append(X)

print(max(box))

Submission status: Time Limit Exceeded

Solution code:
import math
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: Time Limit Exceeded

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

if B > N:
    ans = int(A*N/B)
    print(ans)
else:
    t = int(A*N/B)- A*int(N/B)
    ans = 0
    x = (N//B)*B - 1
    while True:
        temp = int(A*x/B) - A*int(x/B)
        # if ans > temp:
        #     break
        # ans = temp
        ans = max(ans, temp)
        x -= B
        if x < 0:
            break
    print(max(ans, t))

Submission status: Time Limit Exceeded

Solution code:
import bisect
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.insert(bisect.bisect_left(x,y),y)
else:
  for i in range(b):
    y = int(a*i/b) - a*int(i/b)
    x.insert(bisect.bisect_left(x,y),y)

print(x[-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_v = 0
for i in range(1, N + 1):
    current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
    max_v = max(max_v, current_max_v)
    if i != 1 and current_max_v < current_max_vb:
        break
    current_max_vb = current_max_v
print(max_v)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N =  map(int,input().split())
ans = set()
bef = 0
for x in range(1,N+1):
    cal = math.floor(A*x/B)-A*math.floor(x/B)
    ans.add(cal)
    if cal < bef:
        break
    else:
        bef = cal
print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = map(int, input().split())
s = 0
for i in range(1, n + 1):
    s = max(s, int(a * i / b) - a * int(i / b))

print(s)

Submission status: Time Limit Exceeded

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

def f(t):
    return int(t)

Max_x=0

for i in range(N):
    if f(A*i/B)-A*f(i/B)<f(A*(i+1)/B)-A*f((i+1)/B):
        Max_x=i+1
        
print(f(A*Max_x/B)-A*f(Max_x/B))

Submission status: Time Limit Exceeded

Solution code:
import math

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(0, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R >= maxR:
        maxR = R
        maxX = x
print (maxR)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int,input().split())
max = 0
i=N
while(1):
 cal = int((A*i)/B) - A*int(i/B)
 if(cal > max):
  max =cal
 i += -1
 if(i < 0):
  print(max)
  break;

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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
    first=0

    for x in range(N+1):
        rem = x%B
        if x == 0:
            first=rem
        elif rem == first:
            break
        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: Time Limit Exceeded

Solution code:
import math

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

i = 1
while i <= N:
    ans = max(((A * (i-1) // B) - A * ((i-1) // B)),((A * (i) // B) - A * ((i) // B)))
    i = i + 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

A = input_line[0]
B = input_line[1]
N = input_line[2]
N += 1
TEST_LIST=[]

for i in range(N):
    TEST_LIST.append(int((A * i) / B) - A * int(i / B))

print(max(TEST_LIST))

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N =list(map(int,input().split()))
def floor(a):
  if a.is_integer():
    return(int(a))
  else:
  	return(int(math.ceil(a)-1))
_che = 0
x=0
while x<=N:
  if A*x > B:
    y = floor((A*x)/B) - A*floor(x/B)
    if _che < y:
      _che = y
  x+=1
print(_che)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for x in range(int(n), 0, -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n%b
    ret = f(a, b-1, b)
    for j in range(1, k+1):
        ret = max(ret, f(a, b*k-1, b))
    print(ret)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
m = 0
if a-b==1:
    print(n)
elif b-a==1:
    print(n-1)
else:
    for i in range(n+1):
        ch = math.floor(a*i/b)-a*math.floor(i/b)
        m = max(m,ch)
        if m!=0 and ch==0:
            break
    print(m)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
s = input().split()

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

result = 0

start = N - (N // B) * B

for x in range(start, N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result)

Submission status: Time Limit Exceeded

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

for x in range(n+1):

    if (int(a*x/b)-a*int(x/b))>=m:

        m=int(a*x/b)-a*int(x/b)

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

Submission status: Time Limit Exceeded

Solution code:
p = input().split()
k =[int(s) for s in p]
a = k[0]
b = k[1]
n = k[2]
t = []
for i in range(1,n+1):
    c_1 = a*i
    c = c_1//b
    d_1 = i//b
    d = d_1*a
    e = c - d
    t.append(e)
print(max(t))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
mx = 0
p = N
q = B

if B <= N:
    mx = math.floor(A / B * q) - math.floor(q / B) * A
    while mx == 0:
        q -= int(B / 20)
else:
    mx = math.floor(A / B * p) - math.floor(p / B) * A
    while mx == 0:
        p -= int(N / 20)

print(mx)

# for x in range(1, 35):
#     print(math.floor(9 /23 * x) - math.floor(x / 23) * 9)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
a=input().split()
A=int(a[0])
B=int(a[1])
N=int(a[2])
max=math.floor(A*0/B)-A*math.floor(0/B)
for i in range(N):
  if math.floor(A*(i+1)/B)-A*math.floor((i+1)/B)<max:
    print(max)
    sys.exit()
  max=math.floor(A*(i+1)/B)-A*math.floor((i+1)/B)
print(max)

Submission status: Time Limit Exceeded

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

for x in range(n+1):
    f = (a*x)//b - a* (x//b)
    if f >= ans:
        ans = f

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 8: 
    for i in range(0,10**7):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**6-10**5-10**4-10**3-10**2,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))