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
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	for i in range(1,n+1):
		f = math.floor((a*i)/b)
		s = math.floor(i/b)
		temp = int(f) - (a*int(s))
		if(temp > ans):
			ans = temp
	print(ans)

Submission status: Time Limit Exceeded

Solution code:
def floor(x):
    return int(x)

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])
max = 0
for x in reversed(range(N+1)):
    if int(x/B) != 0:
        continue
    else:
        max = int(A * x / B) - A * int(x / B)
        break
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math

data = str(input())
data = data.split(" ")

answer = 0
for i in range(int(data[2])+1):
  first = (int(data[0])*i)//int(data[1])
  second = int(data[0]) * (i//int(data[1]))
  result = first - second
  if result > answer:
    answer = result
print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,n = map(int,input().split())
x = 0
m = []
while x<=n:
  k = (a*x//b) - a*(x//b)
  math.floor(k)
  x += 1
  m.append(k)
m.sort()
print(m[-1])

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(N+1):
    tmp = ((A*i)//B) - (A*(i//B))
    if tmp >= ans:
        ans = tmp
    else:
        break
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
a, b, n = map(lambda x: int(x), input().split())
x = b - 1
t = 2
maxnum = -1;

while x < n:
  x = t * b - 1
  tmp = math.floor(a * x / b) - a * math.floor(x / b)
  if maxnum < tmp:
    maxnum = tmp
  t += 1

x = n
tmp = math.floor(a * x / b) - a * math.floor(x / b)
if maxnum < tmp:
  maxnum = tmp
print(maxnum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N=map(int, input().split(" "))
m=0
re=0
for x in range(N+1):
    re=math.floor(float(A*x)/float(B))-A*math.floor(float (x)/float (B))
    m=max(m,re)
print(m)

Submission status: Time Limit Exceeded

Solution code:
abn = input().split()
a = int(abn[0])
b = int(abn[1])
n = int(abn[2])

x = 0
maxi = -1
while x <= n and int(a*x/b) - a*int(x/b) >= int(a*(x-1)/b) - a*int((x-1)/b):
    if int(a*x/b) - a*int(x/b) >= maxi:
        maxi = int(a*x/b) - a*int(x/b)
        x += 1
    else:
        break

print(maxi)

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):
    ans=max(ans,math.floor(a*i/b)-a*math.floor(i/b))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = input().split()
max = 0
for i in range(int(N)+1):
    temp = i/int(B) -int(i/int(B))
    if temp > max:
        max = temp

print(int(max*int(A)))

Submission status: Time Limit Exceeded

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

if B > N:
    reverse = True
else:
    reverse = False

if reverse:
    for x in reversed(range(1, N + 1)):
        if x == B:
            break
        else:
            value = int(A * x / B) - A * int(x / B)
            if answer <= value:
                answer = value
else:
    for x in range(1, N + 1):
        if x == B:
            break
        else:
            value = int(A * x / B) - A * int(x / B)
            if answer <= value:
                answer = value

print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    print(max_val)

Submission status: Time Limit Exceeded

Solution code:
from math import gcd
a,b,n=map(int,input().split())
t=a*b//gcd(a,b)
if a==1:
    print(0)
    exit()

ans=0
if n%t!=0:
    n%=t

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


print(ans)

Submission status: Time Limit Exceeded

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

x = 0
now = 0
result = 0
for i in range(n+1):
    x = i
    now = (((a * x)//b)) - (a * (x//b))
    #now = math.ceil(((a * x)/b)) - (a * math.ceil(x/b))
    #print("now=",now,"x=",x)
   
    result = max(result,now)

print(result)

Submission status: Time Limit Exceeded

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


floor_num=[]
for x in range(N+1):
    if x>=B:
        break
    floor_num.append(int(A*x/B)-A*int(x/B))

print(max(floor_num))

Submission status: Time Limit Exceeded

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

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))
_list = [floor((A*x)/B) - A*floor(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())
range_list=range(N+1)
max_value=0
for i in range(N+1):
    check_value=math.floor(A*i/B)-A*math.floor(i/B)
    if(max_value<=check_value):
        max_value=check_value
print(max_value)

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 )) 
print(max(func))

Submission status: Time Limit Exceeded

Solution code:
def floor(a, b, x):
    ans = (a * x // b) - a * (x // b)
    return ans

a,b,n=map(int,input().split())
max = 0
if b - 1 > n:
    x = n
else:
    x = b - 1

while x <= n:
    tmp = floor(a,b,x)
    if max < tmp: max = tmp
    x += b

print(max)

Submission status: Time Limit Exceeded

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


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

index = 1
prev = -1
max_num = -1
flag = True
while flag and index <= N:
    tmp = calc(index)
    if tmp < prev:
        flag = False
    else:
        prev = tmp
    if max_num < tmp:
        max_num = tmp

    index += 1

print(max_num)

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(n+1):
        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:
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import math


A, B, N = MAP()


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


x = 0
flag = 0
while True:
    if f(x, A, B) > 0:
        flag = 1
    if f(x, A, B) == 0:
        y = x - 1
        if flag == 1:
            break
    x += 1

if N < y:
    print(f(N, A, B))
else:
    print(f(y, A, B))

Submission status: Time Limit Exceeded

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

print(res)

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N=map(int,input().split())
result=0
if B<=N:
	x=B-1
	while x<=N:
	  tmp=math.floor(A*x/B)-A*math.floor(x/B)
	  if tmp>result:
	    result=tmp
	  x+=B
if B>N:
	result=math.floor(A*N/B)-A*math.floor(N/B)
if B==1:
  print(0)
else:
  print(result)

Submission status: Time Limit Exceeded

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

import math

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

maxnum = 0

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


print(maxnum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#-*- coding: utf-8 -*-
import math
a,b,n = map(int,input().split())
ma = 0
for i in range(1,n+1):
    ans = math.floor(a*i/b) - (a * math.floor(i/b))
    ma = max(ma,ans)

print(ma)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = 0
ans_before = 0
ans_list = []
for i in range(N+1):
  ans = int(A*i/B)-A*int(i/B)
  #print(ans_before,ans)
  if(ans_before<=ans):
    ans_before = ans
  #print("ans",ans)
  
print(ans_before)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

Submission status: Time Limit Exceeded

Solution code:

a,b,n=map(int,input().split())
i=0
while True:
    if b*i<=n:
        i+=1
    else:
        break
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
    num=int(A*i/B)-A*int(i/B)
    if max_num<=num:
        max_num=num
    else:
        break
    
print(max_num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def Ans(x):
    s=math.floor(a*x/b)
    t=a*math.floor(x/b)
    return s-t

ans=0
for i in range(b//a,n+1):
    ans=max(Ans(i),ans)

print(Ans(min(b-1,n)))

Submission status: Time Limit Exceeded

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

for i in range(N+1):
	x=int(A*i/B)
	y=int(i/B)
	z=x-A*y
	if M<z:
		M=z
print(M)

Submission status: Time Limit Exceeded

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

mx = -1
for x in reversed(range(1, N+1)):
  count = 0
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 1000000:
    break
print(mx)

Submission status: Time Limit Exceeded

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


floor_num=[]
for x in range(N+1):
    floor_num.append(int(A*x/B)-A*int(x/B))

print(max(floor_num))

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)-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())
x = N // 2
def floor(t):
    return math.floor(t)
li = []
if B > N:
    for i in range(1, N + 1):
        li.append(floor((A*i) / B) - A * floor(i/B))
else:
     for i in range(1, B + 1):
        li.append(floor((A*i) / B) - A * floor(i/B))
print(max(li))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int, input().split())
ans = 0
for i in range(1, 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())

mx = -1
for x in reversed(range(1, N+1)):
  count = 0
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 3000000:
    break
print(mx)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

Submission status: Time Limit Exceeded

Solution code:
from math import floor
A,B,N  = map(int,input().split())
num = 0
for x in range(0,N+1):
    tmp = floor((A*x)/B) - (A * floor(x/B))
    if num < tmp:
        num = tmp
    elif tmp < num:
        break
print(num)

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))
_list = []
for x in range(N+1):
  y = floor((A*x)/B) - A*floor(x/B)
  _list.append(y)
print(max(_list))

Submission status: Time Limit Exceeded

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

max = (a*2)//b - a*(2//b)

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(max)

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, int(a*i/b)-a*int(i/b))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(n,n-10000000,-1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Time Limit Exceeded

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

for i in range(N+1):

    pre = (A*i//B) - A * (i//B)

    if(pre>=ans):
        ans = pre


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

i = 0
ans = 0
flag = 0

while i <= n:
    x = (a*i//b) - (a*(i//b))
    if x > 0:
        flag = 1
    if flag and x == 0:
        print(ans)
        sys.exit()
    ans = max(ans, x)
    i += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
abn = input().split()
a = int(abn[0])
b = int(abn[1])
n = int(abn[2])

maxi = 0
for x in range(0, n+1):
    if int(a*x/b) - a*int(x/b) >= maxi:
        maxi = int(a*x/b) - a*int(x/b)
print(maxi)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
x = 0
ans1 = 0
while x <= N and x <= 5*10**6:
    ans = int((A*x)/B) - A * int(x / B)
    ans1 = max(ans1, ans)
    x += 1

print(ans1)

Submission status: Time Limit Exceeded

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


print(max)

Submission status: Time Limit Exceeded

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 5000000:
    break
print(mx)

Submission status: Time Limit Exceeded

Solution code:
def main():
    max = 0
    a, b, n = map(int, input().split())
    if n < b:
        max = int(a*n/b)
    else:
        for i in range(1, n+1):
            ans = int(a*i/b) - a*int(i/b)
            if max < ans:
                max = ans

    return max

if __name__ == '__main__':
    print(main())

Submission status: Time Limit Exceeded

Solution code:
A, B, N = list(map(int,input().split()))
def max_val(a, b, n):
  pat = [ i for i in range(b-1, n+1, b)]
  maxv = 0
  for x in pat+[n]:
    maxv = max(maxv, int(a*x/b) - a*int(x/b))
    return maxv

  return maxv
 

print(max_val(A,B,N))

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int, input().split())
answer=0
import math
for i in range(1,N+1):
    newans=math.modf(i/B)[0]*A
    newans//=1
    answer=newans if newans>answer else answer
print(int(answer))

Submission status: Time Limit Exceeded

Solution code:
import math
a,b,c = map(int,input().split())
maxcnt = -99999
if c <= b-1:
	for x in range(c+1):
		cnt = (a*x)//b - a*(x//b)
		if cnt > maxcnt:
			maxcnt = cnt
else:
	x = b-1
	maxcnt = math.floor(a*x/b) - a* math.floor(x/b)
print(maxcnt)

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
p = 10**9+7
ans = 0
for x in range(n+1):
 c = (int((a*x)%p/b))%p
 d = (int(x/b))%p
 e = (c - a*d)%p
 ans = max(ans, e)
print(ans)

Submission status: Time Limit Exceeded

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


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

index = 1
prev = -1
max_num = -1
flag = True
while flag and index <= N:
    tmp = calc(index)
    if tmp < prev:
        flag = False
    if max_num < tmp:
        max_num = tmp

    index += 1

print(max_num)

Submission status: Time Limit Exceeded

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

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):
    y = math.floor((a*x)/b) - a * math.floor(x/b)
    ans_list.append(y)

print(max(ans_list))

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, int((a*i/b) - (a*i/b)%1 -(a*((i/b) - (i/b)%1))))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

for x in range(0,n+1):
    now=(a*x//b)-a*(x//b)
    if now>=max:
        max=now
print(max)

Submission status: Time Limit Exceeded

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

ans = [(a*i//b) - a*(i//b) for i in range(1, min(b, n)+1)]

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
a = int(data[0])
b = int(data[1])
n = int(data[2])

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

Submission status: Time Limit Exceeded

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

temp_prev = 0
temp_curr = 0
x = 0.0
while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr < temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Time Limit Exceeded

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

tmp = 0
a = 0
for i in range(B - 1, N + 1, B):
    if (s := (A * i) // B - A * a) > 0:
        tmp = max(s, tmp)
        a += 1
    else:
        break
    
for i in range(N, N - N % B - 1, -1):
    if (s := (A * i) // B - A * (i // B)) > 0:
        tmp = max(s, tmp)
    else:
        break

print(tmp)

Submission status: Time Limit Exceeded

Solution code:
import math

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

m = 0
n = 1

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

def Bceil(x):
  return B*(math.floor((x+1)/B)+1)-1

while n<N:
  c = Bceil(n)
  n = min(N, c)
  m = max(cal(n), m)
  
print(m)

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(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())
maxval=0
for x in range(N+1):
    if(maxval<=math.floor(A*x/B)-A*math.floor(x/B)):
        maxval=math.floor(A*x/B)-A*math.floor(x/B)
        ans=x
print(maxval)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(n,n-100000000,-1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
a,b,n = map(int,input().split())
mat = np.array([])
x=1
for x in range(1,n+1):
  f = int((a *x)/b)
  g = a *(int(x/b))
  mat = np.append(mat,f-g)
  x +=1

ans = int(np.max(mat))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(max1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A*B):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,N=map(int,input().split())
mx=0
for x in range(0,N//2):
    c=(A*x)//B-A*(x//B)
    d=(A*(N-x))//B-A*((N-x)//B)
    mx=max(mx,c,d)
print(mx)

Submission status: Time Limit Exceeded

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]

def a(A,B,x): return (A*x//B)-A*(x//B)

def main():
    A,B,N = MI()
    max = 0
    for x in range(0, N+1):
        if max < a(A,B,x):
            max = a(A,B,x)
    
    print(max)



    


if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
import math

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

x = 0
max_x = 0

while x <= n:
    val = math.floor(a * x / b) - a * math.floor(x / b)
    if val > max_x:
        max_x = val
    x += 1

print(max_x)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
x = 0
ans1 = 0
while x <= N and x <= 10**7:
    ans = int((A*x)/B) - A * int(x / B)
    ans1 = max(ans1, ans)
    x += 1

print(ans1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
A,B,N = map(int,input().split())
ans = 0
flag = False
for i in range(1,N+1):
    t = math.floor(A*i/B)
    s = A*math.floor(i/B)
    if t-s >= 1:
        flag = True
    if flag and t-s == 0:
        break
    ans = t-s
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# map(int,input().split())
# int(input())
import math
a,b,c = map(int,input().split())
# if a< b 定まらん
# if a>=b a-1
# cの値による？c <= a-2 のとき.
maxcnt = -99999
if c <= b-1:
	for x in range(c+1):
		cnt = math.floor(a*x/b) - a* math.floor(x/b)
		if cnt > maxcnt:
			maxcnt = cnt
else:
	x = b-1
	maxcnt = math.floor(a*x/b) - a* math.floor(x/b)
print(maxcnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

a, b, n = map(int, input().split())
ans_list = []
#y = math.floor((a*x)/b) - a * math.floor(x/b)

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

print(max(ans_list))

Submission status: Time Limit Exceeded

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

ma = math.floor(A*1/B) - A*math.floor(1/B)
cnt=1

for i in range(2,N+1):
  temp = math.floor(A*i/B) - A*math.floor(i/B)
  #print(ma,temp)
  if temp >= ma:
    ma=temp
    cnt=i
print(ma)

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):
    if max< math.floor(A*i*1/B)-A*math.floor(i*1/B):
        max= math.floor(A*i*1/B)-A*math.floor(i*1/B)
print(max)

Submission status: Time Limit Exceeded

Solution code:
import math
A, B, N = map(int, input().split())
x = 0
ans1 = 0
while x <= N and x <= 10**9:
    ans = int((A*x)/B) - A * int(x / B)
    ans1 = max(ans1, ans)
    x += 1

print(ans1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

max_r = 0
for i in range(B):
  if i <= N:
    max_r = max(max_r, i/B)

res = int(max_r * A)
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def func(x): return (A * x) // B - A * (x // B)

ans = 0
for i in range(1, min(B, N)+1):
    ans = max(ans, func(i))
print(ans)

Submission status: Time Limit Exceeded

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