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:
a, b, n = map(int, input().split())
if a == 1 or b == 1:
    print(0)
else:
    ans = 0
    prev = 0
    for x in range(n+1):
        tmp = (a*x)//b - a*(x//b)
        if prev > 0 and tmp == 0:
            ans = prev
            break
        prev = tmp
    else:
        ans = prev
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max = 0
for i in range(1,N+1):
    m = int(A*i/B)-A*int(i/B)
    if m>max:
        # print('i:', i)
        # print('m:', m)
        max = m
# print(max)

if N<B: m=N
else: m=B-1



l = int(A*m/B)-A*int(m/B)
print(l)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

c=0
l=list()
for i in range(1,n+1):
  c=max(c,floor(a*i/b)-a*floor(i/b))
print(c)

Submission status: Time Limit Exceeded

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

f = 0
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:
A,B,N = input().split()
A = int(A)
B = int(B)
N = int(N)
ans = 0
for x in range(N+1):
    
    if x < B:
        z = A*x
        if z < B:
            ans_2 = 0
        else:
            ans_2 = (z)//B
    else:
        z_2 = x//B
        ans_2 = (z)//B - (A * (z_2))
    if ans < ans_2:
        ans = ans_2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,n=map(int,input().split())
sum=0
x=n
while x!=0:
	ans=math.floor(A*x/B)-A*math.floor(x/B)
	if sum<ans:
		sum=ans
	x-=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
temp=[i for i in range(1,N+1)]
y=0
for i in temp:
    z=int(A*i/B)-A*int(i/B)
    if z>y:
        y=z

print(y)

Submission status: Time Limit Exceeded

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

n = [int(x) for x in range(1,N+1)]

answer_list=[]
for x in n:
    Y = x//B
    answer = int(A*x/B) - A * Y
    answer_list.append(answer)
print(max(answer_list))

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = []
old = 0
count = 0
for a in range(N, -1, -1):
    count += 1
    new = int(A*a/B) - A*int(a/B)
    ans.append(new)

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = None
a_max = None

for _x in range(N):
    x = min((B - 1), N) * (_x+1)
    if x > N:
        break
    # print(x)
    a = x/B-int(x / B)
    # print(int(a * A))
    sa = int(a*A)
    # s = int((A * x) / B) - A * int(x / B)
    if a_max == None:
        a_max = sa
    elif sa > a_max:
        a_max = sa

print(a_max)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
m = 0
x = 1
ax = a*x
while ax/b <0.01:
    x*=10
    ax = a*x
    if x>n:
        x//10
        break
if a-b==1:
    print(n)
elif b-a==1:
    print(n-1)
else:
    for i in range(x,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 = map(int, input().split())
ans = []

for x in range(1, N+1):
    calculation1 = math.floor((A*x)/B)
    calculation2 = A*math.floor(x/B)
    calculation = calculation1 - calculation2
    ans.append(calculation)

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = 0
max_score= -float('inf')
score_list = []
for x in range(N+1) :
    score, _ = math.modf(x/B)
    if score in score_list:
        break
    if score > max_score:
        max_score = score
    score_list.append(score)

print(int(A*max_score))

Submission status: Time Limit Exceeded

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

ans = 0

for v in range(1, n+1):
    if ans < ((((a * v)/ b) // 1) - (a * ((v/b)//1))):
        ans = ((((a * v)/ b) // 1) - (a * ((v/b)//1)))
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(int, input().split())
def calc(a,b,x):
    tmp = math.floor((a*x/b)) - a*math.floor(x/b)
    return tmp
l = [ calc(a,b,i) for i in range(n+1)]
print(max(l))

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
max = 0
s = int(b/a)
f = n+1
if b < n:
    f = b+1
for i in range(s,f):
    buf = a*(i%b)-(a*i)%b 
    if buf > max:
        max = buf

print(int(max/b))

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
import collections
# X = int(input())
A, B, N = map(int, input().split())

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

else:
	print(int(A*N/B))

Submission status: Time Limit Exceeded

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

if(n<b):
    ma = (a*n)//b - (a* (n//b))
else:
    ma = (a*(b-1))//b - (a*((b-1)//b))
    for x in range(b,n+1):
        
        num = (a*x)//b - (a*(x//b))
        if(ma > num):
            break
        ma = num
        

print(ma)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

for x in range(0, n+1):
    value = floor(a*x/b) - a * floor(x/b)
    result.append(value)

print(max(result))

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = [int(i)for i in input().split()]
tmpmax = 0
breakflag=False
for i in range(N+1):
  tmp=math.floor(A*i/B)-A*math.floor(i/B)
  if tmp > tmpmax:
    tmpmax = tmp
  elif tmp < tmpmax:
    breakflag=True
  elif tmp == tmpmax and breakflag:
    break
print(tmpmax)

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n=map(int,input().split())
x=1
m=0
while(True):
	val= math.floor((a*x)/b)-a*math.floor(x/b)
	# print(val)
	if(val>m):
		m=val
	if(x%b==0 or x>=n):
		break
	x+=1
print(m)

Submission status: Time Limit Exceeded

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

from math import floor

maxi = 0
for i in range(n):
    maxi = max(maxi, floor((a*(n-i))/b) - a*floor((n-i) / b)) 
    maxi = max(maxi, floor((a*(i))/b) - a*floor((i) / b))
print(int(maxi))

Submission status: Time Limit Exceeded

Solution code:
Ns,Ms,Qs=input().split()
A=int(Ns)
B=int(Ms)
N=int(Qs)
ans=-1*A
for i in range(N+1):
    if ans<int(A*i/B)-A*int(i/B):
        ans=int(A*i/B)-A*int(i/B)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
x = 0
c = b-1
while c <= n:
    x += 1
    c += b 
    
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: Time Limit Exceeded

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

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

for x in range(1,N+1):
    ans = (x % B) / B * A
    if ans > z:
        z = ans
print(int(z))

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b//a, b+a):
        tmp = (a*x)//b - a*(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())
score=0
score_list=[]*N
for i in range(N):
    score=(A*(i+1)//B)-A*((i+1)//B)
    score_list.append(score)
print(max(score_list))

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int, input().split())
ans = -1145141919810931931
Flag = True
for x in range(1, N+1, max(1, int(B/A) - 1)):
    a = int(A*x/B) - A*int(x/B)
    if a>=ans:
        ans = a
        Flag = True
    elif Flag:
        Flag = False
    else:
        break

a = int(A*N/B) - A*int(N/B)
if a>ans:
    ans = a
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = (int(x) for x in input().split(' '))

import sys

max = sys.float_info.min
for x in range(N + 1):
  ans = int(A*x/B) - A * int(x/B)

  if ans > max:
    max = ans

print(int(max))

Submission status: Time Limit Exceeded

Solution code:
def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N >= B:
        for x in range(B-1, N+1, B):
            k = x / B
            ans = int(A*k) - int(k)
            if ans > mini:
                mini = ans
    else:
        ans = int(A*(N)/B)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        for i in range(0,n//b+1,20000):
            ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
            now=max(now,ans3)
        print(max(ans,ans2,now))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))

A,B,N =line[0],line[1],line[2]

ans = (N+1)//B
if ans ==0:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    kouho =[0 for j in range(ans)]
    for i in range(1,ans+1):
        x= i*B-1
        kouho[i-1]=(math.floor(A*x/B)-A*math.floor(x/B))
    
    kouho.append(math.floor(A*N/B)-A*math.floor(N/B))
    print(max(kouho))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import math
A, B, N = map(int, input().split())
tmp = 0
ans = 0
for i in range(1, N+1):
    tmp = math.floor(A * i / B) - A * math.floor(i / B)
    ans = max(tmp, ans)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = input().split()
A = int(A)
B = int(B)
N = int(N)
ans = 0
for x in range(N+1):
    z = A*x
    if x < B:
        if z < B:
            ans_2 = 0
        else:
            ans_2 = (z)//B
    else:
        z_2 = x//B
        ans_2 = (z)//B - (A * (z_2))
    if ans < ans_2:
        ans = ans_2

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

a, b, n = map(int, input().split())
step = math.ceil(1/10**3)
array = range(1, n+1, step)
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1, N+1):
  ans.append((A*i)//B-A*(i//B))    
  
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
A = list(map(int, input().split()))
n=1
lis = []
while n <= A[2]:
    lis.append(int(math.floor(A[0]*n/A[1])-A[0]*math.floor(n/A[1])))
    n = n + 1
print(max(lis))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
kind=set()
bef=-100
for i in range(1,n+1):
    num=calc(i)
    if bef!=num:
        if num in kind:
            break
    kind.add(num)
    bef=num
print(max(kind))

Submission status: Time Limit Exceeded

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

for i in range(int(n/4),n+1):
    if b>n:
        lis.append(int(a*n/b))
        break
    k = int(a*i/b)-a*int(i/b)
    lis.append(k)
    
print(max(lis))

Submission status: Time Limit Exceeded

Solution code:
from math import floor


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

ans = 0
for x in range(1, n + 1):
    aa = floor(a * x / b)
    bb = a * floor(x / b)

    diff = aa - bb

    if diff > ans:
        ans = diff

print(ans)

Submission status: Time Limit Exceeded

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))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        for i in range(0,n//b+1,10000):
            ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
            now=max(now,ans3)
        print(max(ans,ans2,now))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

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

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 >= 7:
    for i in range(0,10**6+10**5):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-3*10**6,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))

Submission status: Time Limit Exceeded

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

x = 0
max_score= -float('inf')
for x in range(N+1) :
    score, _ = math.modf(x/B)
    if score > max_score:
        max_score = score

print(int(A*max_score))

Submission status: Time Limit Exceeded

Solution code:
import math

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

i = 1
maxnum = 1
while i <= N:
    if (math.floor(A * (i-1) // B) - A * ((i-1) // B)) < math.floor((A * (i) // B) - A * ((i) // B)):
        maxnum = math.floor((A * (i) // B) - A * ((i) // B))
        i = i + 1

print(maxnum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

def siki(A, B, X):
	return math.floor((A*X)/B) - A*math.floor(X/B)

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

if N < B:
	k = N
else:
	k = B
for i in range(1, k+1):
	if max_value < siki(A,B,i):
		max_value = siki(A,B,i)

print(max_value)

Submission status: Time Limit Exceeded

Solution code:
import math

a = [int(i) for i in input().split()]

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

result = 0
for i in range(1, a[2]+1):
    result = max(result, calc(a[0], a[1], i))

print(result)

Submission status: Time Limit Exceeded

Solution code:
import math


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


s = input()
input_arr = s.split()

a = int(input_arr[0])
b = int(input_arr[1])
n = int(input_arr[2])

if a > b:
    if b <= n:
        x_max = b
    else:
        x_max = n

    v = []

    for i in range(x_max):
        v.append(calc(a, b, i+1))

    print(max(v))
else:

    x_max = n

    v = []

    for i in range(x_max):
        v.append(calc(a, b, i+1))

    print(max(v))

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)

Submission status: Time Limit Exceeded

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

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

print(max(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(_max)

Submission status: Time Limit Exceeded

Solution code:
from math import floor, ceil
a, b, n = map(int, input().split())
ans = 10 ** 6 * (-1)
x = 1
while x <= n:
    tmp = floor(a * x / b) - a * floor(x / b)
    ans = max(ans, tmp)
    x = ceil((floor(a * x / b) + 1) * b / a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
c=list(map(int,input().split()))
bunsi=c[0]
bunbo=c[1]
n=c[2]
k=n//bunbo
d=[n]
if k!=0:
    for i in range(0,k):
        d.append(bunbo*(i+1)-1)
#dの中には候補となるxが入った
def floor(x):
    return ((bunsi*x)//bunbo)-(bunsi*(x//bunbo))
if len(d)>=2:
    print(max(floor(d[0]),floor(d[-1]),floor(d[-2])))
if len(d)==1:
    print(floor(d[0]))

Submission status: Time Limit Exceeded

Solution code:
import math

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

i = 1
maxnum = 1
while i <= N:
    if ((A * (i-1) // B) - A * ((i-1) // B)) < ((A * (i) // B) - A * ((i) // B)):
        maxnum = ((A * (i) // B) - A * ((i) // B))
        i = i + 1

print(maxnum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0

for v in range(1, n+1):
    m = ((a * v)/ b) // 1
    l = a * ((v/b)//1)
    if ans < (m - l):
        ans = (m - l)
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
#flag = 0
A_B_N = input().split(" ")
result = 0
tmp = 0
A_B_N[0] = int(A_B_N[0])
A_B_N[1] = int(A_B_N[1])
A_B_N[2] = int(A_B_N[2])
for i in range(1,A_B_N[2]+1):
    tmp =int(i * A_B_N[0]/A_B_N[1]) - A_B_N[0] * int(i/A_B_N[1])
    #print(tmp)
    if tmp >= result:
        result = tmp
print(result)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    a, b, n = map(int, input().split())
    m = 0
    print(max(list(map(lambda x:(a*x)//b - a*(x//b), range(1, n+1)))))
    #  if (a*x)//b - a*(x//b) > m)
    # for _,x in enumerate(range(1, n+1)):
        # p = (a*x)//b - a*(x//b)
        # p = (a*x)//b - a*(x//b)
        # if m < p:
            #m = p
    # print(m)

Submission status: Time Limit Exceeded

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

result = []
for i in range(n):
    result.append(math.floor(a*(i+1)/b) - a*math.floor((i+1)/b))
    if result[i] < max(result):
        break
    
print(max(result))

Submission status: Time Limit Exceeded

Solution code:
import math


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

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

    max_value = -1
    for i in range(1, min(N+1, B + 1)):
        v = target(i)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_value = v
    print(max_value)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
li = list(map(int,input().split()))
a = li[0]
b = li[1]
n = li[2]
max_val = 0
for x in range(1, n+1):
    val = math.floor(a*x/b) - a * math.floor(x/b)
    max_val = max(max_val, val)
print(max_val)

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
def floor(x):
  return int(x//1)
list = []
if N >= B:
  for x in range(B+1):
    list.append(floor((A*x)/B)-(A*floor(x/B)))
else:
    list.append(floor((A*N)/B)-(A*floor(N/B)))
print(max(list))

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
if a == 0 or b == 0:
    print(0)
else:
    ans = 0
    prev = 0
    for x in range(n+1):
        tmp = (a*x)//b - a*(x//b)
        if prev > 0 and tmp == 0:
            ans = prev
            break
        prev = tmp
    else:
        ans = prev
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# ABC165 D

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

    max = 0

    for i in range(n+1):
        res = ((a*i) // b) - a * (i // b)

        if res >= max:
            max = res
    
    print(max)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

a, b, n = map(int, input().split())
array = range(1, n+1, math.ceil(1/10**5))
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)

Submission status: Time Limit Exceeded

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))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        for i in range(0,n//b+1,1000):
            ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
            now=max(now,ans3)
        print(max(ans,ans2,now))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

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

Submission status: Time Limit Exceeded

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

if(n<b):
    ma = (a*n)//b - (a* (n//b))
else:
    ma = (a*(b-1))//b - (a*((b-1)//b))
    for x in range(b,n+1):
        num = (a*x)//b - (a*(x//b))
        if(ma < num):
            ma = num

print(ma)

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 >= 7:
    for i in range(0,10**6+10**5):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-5*10**6,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))

Submission status: Time Limit Exceeded

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

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

ans = max(buf)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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/16), -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:
import math
A,B,N = map(int,input().split())
res = 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
    else:
        break
print(res)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
m=0
if n<=(10**7):


    for x in range(n+1):
        l=int(a*x/b)-a*int(x/b)

        if l>=m:

            m=l

else:
    for x in range(10**6,n+1):


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

            m=l
print(m)

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import sqrt, floor
from collections import Counter, defaultdict, deque

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


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


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


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    a, b, n = MI()
    max = 0
    for x in range(1, n + 1):
        r = floor((a * x) / b) - a * floor(x / b)
        if max < r:
            max = r

    print(max)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_s = []
j = 0
if n > 10**6:
    for i in range(n,10*6,-1):
        num = int((a*i)/b) - a*int(i/b)
        max_s.append(num)
    print(max(max_s))
else:
    for i in range(n,0,-1):
        j += 1
        if j == int(10**6):
            break
        else:
            num = int((a*i)/b) - a*int(i/b)
            max_s.append(num)
    print(max(max_s))

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import ceil,floor
A, B, N = map(int, input().split())
maxResult = 0

for x in range(N + 1):
  result = floor((A * x)/B) - A * floor(x/B)
  if (maxResult < result):
    maxResult = result
print(maxResult)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(10**6,N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Time Limit Exceeded

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

l = []
for x in range(1,n+1):
  b2 = x / b
  ans = math.floor(a * b2) - a * math.floor(b2)
  l.append(ans)
print(max(l))

Submission status: Time Limit Exceeded

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))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        for i in range(0,n//b+1,10):
            ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
            now=max(now,ans3)
        print(max(ans,ans2,now))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, N-100000)*A)/B
    init_2 = max(1, N-100000)/B
    start = max(1, N-100000)

    for i in range(max(1, N-100000), N + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    if N > B:
        start = max(B-100000,1)
        init_1 = (max(1, int(B-100000)) * A) / B
        init_2 = max(1, int(B-100000)) / B
        for i in range(max(int(B)-100000,1), max(N,int(B)+1)):
            ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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