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
a, b, n = map(int, input().split())

result = []
if n < b:
    print(math.floor(a * n / b) - a * math.floor(n / b))

else:
    for i in range(1, n+1):
        result.append(math.floor(a * i / b) - a * math.floor(i / b))
    print(max(result))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(A: int, B: int, N: int):
    b=0
    for i in range(N+1):
        a=int((A*i)/B)-A*int(i/B)
        b=max(a,b)
    print(b)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import math


A, B, N = map(lambda x: int(x), input().split(" "))

result = 0
candidates = []
for i in range(0, N+1, B):
    if i <= 1:
        continue
    i -= 1
    candidates.append(i)
try:
    i = candidates[-1]
    temp = math.floor(A*i/B) - A*math.floor(i/B)
    result = max(result, temp)
except:
    pass
temp = math.floor(A*N/B) - A*math.floor(N/B)
result = max(result, temp)

print(result)

Submission status: Time Limit Exceeded

Solution code:
A, B, N = map(int,input().split())
fivex = 0
i = 1
ans = 0
while True:
    fivex = i * B
    if (fivex % A == 0):
        x = fivex // A
    else:
        x = fivex // A + 1
    if x > N:
        break
    if i - A *  int(x / B) > ans:
        ans = i - A *  int(x / B)
    i += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

    print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
x = 0
#hashset = set()
maxNum = -1
while x <= n and x <= b:
  num = int(a * x / b) - a *int(x//b)
  #if num in hashset:
  #  break
  #hashset.add(num)
  maxNum = max(maxNum, num)
  x += 1

print(int(maxNum))

Submission status: Time Limit Exceeded

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

def judge(x):
  return math.floor(x*ApB)-A*math.floor(float(x)/float(B))

def ma(N):
  m=0
  for n in range(1,N+1):
    x=judge(n)
    if m<x:
      m=x
  return m

print(ma(N))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))
for i in range(2, N + 1):
    a = math.floor(((A * i) / B)) - A * math.floor((i / B))
    if res < a:
        res = a
print(res)

Submission status: Time Limit Exceeded

Solution code:
import math

a,b,n=map(int,input().split())
num=-100
for x in range(1,n+1):
    num=max(num,math.floor(a*x/b)-a*math.floor(x/b))
print(num)

Submission status: Time Limit Exceeded

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

list=[]
for i in range(N+1):
    list.append(math.floor((A*i)/B)-A*(math.floor(i/B)))

print(max(list))

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8
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(tmp, ans)

print(ans)

Submission status: Time Limit Exceeded

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


def unko(x):
    return int(a * x / b) - a * int(x / b)


res = 0
for i in range(int(n / 2), n + 1):
    if unko(i) > res:
        res = unko(i)
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while i % B != 0:
  i = i - 1
  
i = i - 1
if i < 0:
  ans = (A * N) // B - A * (N // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)

Submission status: Time Limit Exceeded

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

ans = max(mat)
print(ans)

Submission status: Time Limit Exceeded

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

Max=0
x=0
while x<=N:
	num=int(A*x/B)-A*int(x/B)
	if num>=Max:
		Max=num
	x=x+1
print(Max)

Submission status: Time Limit Exceeded

Solution code:
import math
d=list(map(int,input().split()))
a=d[0]
b=d[1]
n=d[2]
maxim=0
for i in range(n+1):
  maximy=(math.floor(a*i/b)-a*math.floor(i/b))
  if maximy>maxim:
    maxim=maximy
print(maxim)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import math

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)
        if ans > max:
            max=ans

    print(max)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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)
        x += 1
        if m <= p:
            m = p
    print(m)

Submission status: Time Limit Exceeded

Solution code:
inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
n = int(inp[2])
y = - 10 ** 10
for x in range(n+1):
    z = int(a*x/b) - a*int(x/b)
    if y < z:
        y = z
print(y)

Submission status: Time Limit Exceeded

Solution code:


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

max_ = -A
for x in range(N+1):
    num = int((A*x)/B) - A * int(x/B)
    if num > max_:
        max_ = num
print(max_)

Submission status: Time Limit Exceeded

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

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


    return ans


print(solve())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []

for x in range(n+1):
    li.append(math.floor((a*(x))/b) - a * math.floor(x/b))
print(max(li))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A,B,N = [int(i) for i in input().split()]
x = min(B, N)
floor = lambda A,B,x: (A*x)//B - A*(x//B)
prev = floor(A,B,x)
while True:
    x -= 1
    c = floor(A,B,x)
    if prev <= c:
        prev = c
    else:
        break
print(prev)

Submission status: Time Limit Exceeded

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

if b>n:
    print((a*n)//b)
else:
    p=0
    for i in range(n):
        c=(a*(i+1))//b
        d=((i+1)//b)*a
        q=c-d
        if q>p:
            p=q
        if q<p:
            break

    print(p)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if N < B:
    print(fnc(N))
else:
    ans = 0
    for i in range(B-1, N+1, B):
        s = fnc(i)
        if s > ans:
            ans = s
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from typing import Dict, List, Optional, Set, Tuple


def solve(a: int, b: int, n: int) -> int:
    max_diff = 0
    for x in range(n + 1):
        val = (a * x) // b - a * (x // b)
        if val > max_diff:
            max_diff = val
    return max_diff


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    A, B, N = list(map(int, input().split()))
    # values = []
    # for _ in range(N):
    #     values.append(input().split())
    result = solve(A, B, N)
    print(result)


def print_output(testcase: int, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))
    # 6 digits float precision {:.6f} (6 is the default value)
    # print("Case #{}: {:f}".format(testcase + 1, result))


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


class memoized:
    """Decorator that caches a function's return value each time it is called.
    If called later with the same arguments, the cached value is returned, and
    not re-evaluated.
    """

    def __init__(self, func):
        self.func = func
        self.cache = {}

    def __call__(self, *args):
        try:
            return self.cache[args]
        except KeyError:
            value = self.func(*args)
            self.cache[args] = value
            return value
        except TypeError:
            # uncachable -- for instance, passing a list as an argument.
            # Better to not cache than to blow up entirely.
            return self.func(*args)

    def __repr__(self):
        """Return the function's docstring."""
        return self.func.__doc__

    def __get__(self, obj, objtype):
        """Support instance methods."""
        return functools.partial(self.__call__, obj)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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


# floor(a * x / b) - a * floor(x / b)
#   = floor(a / b * x) - a * floor(x / b)
#   =  (a / b * x // 1) - a * (x / b // 1)
#   =  a / b * x // 1 - a * (x / b // 1)


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

Submission status: Time Limit Exceeded

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

l=sorted(l)
    
print(l[-1])

Submission status: Time Limit Exceeded

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

c=[]

for x in range(n+1):

    c.append(int(a*x/b)-a*int((x/b)))

print(max(c))

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

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 sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res >= m:
        m = res
    elif res == 0:
        break
    else:
        break

print(m)

Submission status: Time Limit Exceeded

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

if N > 10000:
    for x in range(N+1, int(N / 100), -1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
else:
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)

Submission status: Time Limit Exceeded

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


def unko(x):
    return int(a * x / b) - a * int(x / b)


res = 0
for i in range(1, n + 1):
    if unko(i) > res:
        res = unko(i)
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
def formula(x):
    return math.floor(A*x/B)-(A*math.floor(x/B))
A,B,n=[int(x) for x in input().split()]
maxi=formula(1)
for i in range(2,n+1):
    maxi=max(formula(i),maxi)
print(maxi)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, N = MAP()

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    max = 0
    a, b, n = map(int, input().split())
    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:
from math import floor
A, B, N = map(int, input().split())

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

m = 0

for x in reversed(range(1,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:
from math import floor
a,b,n=map(int,input().split())
mx=0
for x in range(1,n+1):
    c=floor((a*x)/b)-(a*floor(x/b))
    if c>mx:
        mx=c
print(mx)

Submission status: Time Limit Exceeded

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

def f(x):
    return floor(A*x/B) - A*floor(x/B)
if B > N:
    print(f(N))
    exit()

ans = 0
for i in range(B-1,N+1,B):
    temp = f(i)
    #print(temp)
    ans = max(ans,temp)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

ans()

Submission status: Time Limit Exceeded

Solution code:
A,B,N = map(int,input().split())
#N=int(input())
#A = list(map(int,input().split()))
#S=str(input())
m=0
if B<N:
    N=B
s=int(B/A)
if s>N:
    print(0)
    exit()
for x in range(s,N+1):
    num=int(A*x/B) - A * int(x/B)

    m=max(num,m)

print(m)

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))
for i in range(2, N + 1):
    if res < math.floor(((A * i) / B)) - A * math.floor((i / B)):
        res = math.floor(((A * i) / B)) - A * math.floor((i / B))
print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
a,b,n = map(int,input().split())
ans = -10**10
for i in range(1,n+1):
    t = (a*i)//b
    f = i//b
    s = t-a*f
    if ans > s:
        break
    else:
        ans = s

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    n = kwargs["n"]
    res = 0

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

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"], kwargs["n"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


a, b, c= map(int, input().split())
t_7 = 2/7

f_table = [a*t//b for t in range(b)]

if c >= b:
    print(f_table[-1])

else:
    x = c
    c_amari = c%b
    c_sho = c//b
    ans =f_table[c_amari]
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

temp = -1 * float('inf')


for x in range(N+1):
    if temp <= math.floor(A*x/B) - A*math.floor(x/B):
        temp = math.floor(A*x/B) - A*math.floor(x/B)
    else:
        break

print(temp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

max_num = -99999999999999999999999

for i in range(n):
    x = i + 1
    num = math.floor(a*x / b) - a * math.floor(x / b)
    
    if num > max_num:
        max_num = num
        
print(max_num)

Submission status: Time Limit Exceeded

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

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 = 0
if a<b:
	for x in range(c+1):
		cnt = math.floor(a*x/b) - a* math.floor(x/b)
		if cnt > maxcnt:
			maxcnt = cnt
else:
	if c <= a-2:
		for x in range(c + 1):
			cnt = math.floor(a * x / b) - a * math.floor(x / b)
			if cnt > maxcnt:
				maxcnt = cnt
	else:
		x = a-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())
ans=0
if N<B:
    for i in range(1,N+1):
        if ((A*i)//B)-A*(i//B)>ans:
            ans=((A*i)//B)-A*(i//B)
else:
    if ((A*(B-1))//B)-A*((B-1)//B)>ans:
            ans=((A*(B-1))//B)-A*((B-1)//B)
print(ans)

Submission status: Time Limit Exceeded

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

print(max)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a, b, n = map(int, input().split())
x = 0
#hashset = set()
maxNum = -1
while x <= n:
  num = int(a * x / b) - a *int(x//b)
  #if num in hashset:
  #  break
  #hashset.add(num)
  maxNum = max(maxNum, num)
  x += 1

print(int(maxNum))

Submission status: Time Limit Exceeded

Solution code:
import math


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

    ans = 0
    for i in range(min(N, B), 1, -1):
        tmp = math.floor(A * i / B) - A * math.floor(i / B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Time Limit Exceeded

Solution code:
import math

A, B, N = map(int, input().split())
l = [0]

for i in range(N + 1):
  s = math.floor(A * i / B) - A * math.floor(i / B)
  if s > max(l):
    l.append(s)
  else:
    pass
print(max(l))

Submission status: Time Limit Exceeded

Solution code:
from math import floor

a, b, n = [int(i) for i in input().split(' ')]
seen = set()
prev = None
seen = set()
for x in range(1, n + 1):
    value = floor((a * x) / b) - a * floor(x / b)
    if prev is None:
        prev = value
        seen.add(value)
        continue
    if value != prev and value in seen:
        print(max(seen))
        break
    seen.add(value)
    prev = value
else:
    print(max(seen))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
for i in range(b[2]+1):
    if b[2]-i <0:
        break
    check = math.floor((b[0]*(b[2]-i))/b[1]) - b[0]*math.floor((b[2]-i)/b[1])
    if check > ans:
        ans=check
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1,N+1):
  r = math.floor(A*i/B) - A*math.floor(i/B)
  res.append(r)
print(max(res))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
A,B,N=map(int,input().split())

min_x = 1
max_x = N

def f(x):
    y = (A*x)//B - A*(x//B)
    return y

def tren_isOK(x1,x2):
    if f(x1) >= f(x2):
        return True
    else:
        return False


def treary_search():
    left = min_x
    right = max_x

    while abs(right - left) >10**(-8):
        p1 = (right + 2*left)/3
        p2 = (2*right + left)/3

        if tren_isOK(p1,p2):
            right = p2
        else:
            left = p1
    
    return right

x=treary_search()
ans=max(f(int(x)),f(int(x)+1))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

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

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

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

Submission status: Time Limit Exceeded

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

cnt=0

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

print(cnt)

Submission status: Time Limit Exceeded

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

while i % B != 0:
  x.append(i % B)
  i = i - 1
  
i = i - 1
if i < 0:
  ans = (A * x[0]) // B - A * (x[0] // B)
else:
  ans = (A * i) // B - A * (i // B)
  
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

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

    M = 0
    for i in range(N, max(0, N - 10 ** 7), -1):
        tmp = func(i)
        if tmp > M:
            M = tmp

    print(M)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

print(max)

Submission status: Time Limit Exceeded

Solution code:
import math as m

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

list = []
flag = 0

list += [m.floor(A * 0 / B) - A * m.floor(0 / B)]

for x in range(1, N + 1):
  list += [m.floor(A * x / B) - A * m.floor(x / B)]
  if list[x] < list[x - 1]:
    print(list[x - 1])
    flag = 1
    break

if flag == 0: print(max(list))