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: Wrong Answer

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

x = list()
for i in range(n):
  y = int(a*i/b) - a*int(i/b)
  x.append(y)

z = sorted(x)
print(z[-1])

Submission status: Wrong Answer

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


def solve(A: int, B: int, N: int):
    answer = 0
    for x in range(1,min(A+1,N+1)):
        answer = max(answer,A*x//B-A*(x//B))
    print(answer)
    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: Wrong Answer

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

if N > B:
    print(int(A * (B - 1) / B))
else:
    print(int(A * N / B))

Submission status: Wrong Answer

Solution code:
import math
A,B,N =list(map(int,input().split()))
def floor(a):
  return(int(math.ceil(x)-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: Wrong Answer

Solution code:
import math
def main(a,b,n):
    res = 0
    r = n // b
    for i in range(1,min(b,n)+1):
        res = max(res,calc(a,b,i))
    for i in range((r-1)*b, n+1):
        res = max(res, calc(a,b,i))
    return res
    
def calc(a,b,x):
    return (math.floor(a*x/b) - a * math.floor(x/b))

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

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

A, B, N = map(int, input().split())
# print(Fraction(A * N, B).__floor__(), Fraction(A * N, B))
# print(A * Fraction(N, B).__floor__())
print(Fraction(A * N, B).__floor__() - A * Fraction(N, B).__floor__())

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B,N = map(int,input().split())
ans = 0
for i in range(A):
    t = A*i//B-A*(i//B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans < t:
        ans = t
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,N= map(int, input().split())
ans = 0
if N>B:
    i = B-1
else:
    i = N
d = (int((A*i)/B) - A *int(i/B))
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=100000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))

for i in range(n):
    if i>teisuu:
        break
    temp=n-i
    maxtemp=max(maxtemp,funcsum(temp))

print(maxtemp)

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


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

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

print(int(a*n / b))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
import math
floor_tmp = math.floor(a * n / b) - a * math.floor(n / b)
print(floor_tmp)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,n = m()

if a > b:
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

"""


a,b,n = m()

if a >= b:
    po = 0
    if b <= n:
        po = b-1
    else:
        po = n
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
for x in range(n, -1, -1):
    tmp = math.floor(a*x/b) - a*math.floor(x/b)
    if x != n:
        if pre > tmp:
            break
        if ma < tmp:
            ma = tmp
    else:
        ma = tmp        
    pre = tmp
print(ma)

Submission status: Wrong Answer

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

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

print(func(A,B,N))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


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


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    A, B, N = MI()
    ans = 0
    s = set()

    for x in range(min(N+1, 10**6)):
        d = (A * x) // B - A * (x // B)
        ans = max(ans, d)
        s.add(d)
        # print(x, d)

    # print(s)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


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

    if N / B < 1:
        x = N
        res = math.floor(A * x / B)
        return print(res)

    x = (N // B) * B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    return print(res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
a = s[0]
b = s[1]
n = s[2]

if n % b == 0:
    n = n - 1

kotae = round(a * ((n / b) - (n // b)) - ((a * n / b) - ((a * n) // b)))

print(kotae)

Submission status: Wrong Answer

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

if n<b:
  ans=int(a*n/b)-a*int(n/b)
if n==b:
  ans=int(a*(n-1)/b)-a*int((n-1)/b)
if n>b:
  r=n%b
  if r>0:
    ans=int(a*r/b)-a*int(r/b)
  else:
    ans=int(a*(r-1)/b)-a*int((r-1)/b)
print(ans)

Submission status: Wrong Answer

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

#print(A)
#print(B)
#print(N)

ret = 0
for i in reversed(range(1, N+1)):
  #print(i)
  temp = math.floor(A * i / B) - A * math.floor(i / B)
  #print(temp)
  if temp > ret:
    ret = temp
    break;
  
print(ret)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    if a == b == n == 1:
        print(0)
    elif b <= n <= b+1:
        print(floor(a*b//n) - a*floor(n//n))
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
if a>n:
    print((n*a)//b - a*(n//b))
else:
    print(((n-1)*a)//b - a*((n-1)//b))

Submission status: Wrong Answer

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

if N // B == 0:
    f, _ = math.modf(N / B)
    ans = math.floor(A * f)
else:
    n = (N // B) * B - 1
    f, _ = math.modf(n)
    ans = math.floor(A * f)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

def f(n):
    return (a*n)//b-a*(n//b)

ans=0
pre=0
now=x//2
ans=f(now)
i=1
while True:
    i+=1
    if x//(2**i)==0:
        break
    pre_1=f(now-x//(2**i))
    pre_2=f(now+x//(2**i))
    if pre_1<pre_2:
        ans=pre_2
        now=now+x//(2**i)
    else:
        ans=pre_1
        now=now-x//(2**i)

for i in range(now-1000,now+1000):
    pre=f(i)
    if ans<pre:
        ans=pre
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
def func(x):
    return math.floor((A*x)/B) - A * math.floor(x/B)

if N < B:
    print(func(N))
else:
    print(A-1)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if n%b==0:
    n -= 1
result = int((a*n)/b)-a*int(n/b)
n -= 1
result = max(int((a*n)/b)-a*int(n/b), result)
print(result)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if n >= b-1:
  print(a-1-a//b)
else:
  print((a*n)//b - a*(n//b))

Submission status: Wrong Answer

Solution code:
a , b , n = map(int , input().split())
l = 0
r = n
ans = 0
while (l < r) :
    mid = (l + r + 1) // 2
    if  (a * mid) // b - a * (mid // b) >= ans :
         l = mid
    else :
        r = mid - 1
print((a * r) // b - a * (r // b))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
m = min(B,N)
num = math.floor((A*m)/B) - A * math.floor(m / B)
print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,n = LI()
    if 2*b >= n:
        print(max((a*n)//b-a*(n//b),(a*(n-1))//b-a*((n-1)//b)))
        return
    ans = 0
    for x in range(max(0,b*((n//b)-20)),n+1):
        ans = max(ans,(a*x)//b-a*(x//b))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:

import math

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

if N <= B:
    print(math.floor(A*N/B))
else:
    print(math.floor(A*(B-1)/B))

Submission status: Wrong Answer

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

if N >= B:
    print(A-1)
else:
    print(N*A//B)

Submission status: Wrong Answer

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

x=min(B-1,N)

print((A+(x%B)+B-1)//B)

Submission status: Wrong Answer

Solution code:
def main():
    ans = 0
    a,b,n = map(int, input().split())
    ans = (a*n)//b - a*(n//b)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
if n%b==0:n-=1
print((a*n)//b-a*(n//b))

Submission status: Wrong Answer

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

cand = [0]

def calc(n):
  return int(a*n/b)-a*int(n/b)

cand.append(calc(n))
cand.append(calc(n-1))
cand.append(calc(b*(n//b) - 1))
cand.append(calc(b*(n//b) - 2))
cand.append(calc(min(n, b-1)))

print(max(cand))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# import bisect  # 二分探索の公式のライブラリをimportする
A, B, N = map(int, input().split())
ans = (int(A*N/B) - A*int(N/B))
# シミュレーション
for i in range(max(N-1000005, 0), N+1):
    ans = max(ans, int(A*i/B)-A*int(i/B))
print(ans)

Submission status: Wrong Answer

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

a,b,n = mp()
x = min(n,b+1)
ans = a*x//b - a*(x//b)
print(ans)

Submission status: Wrong Answer

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

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

print(tmp)

Submission status: Wrong Answer

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 a<b:
	for x in range(min(c+1, a)):
		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: Wrong Answer

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

if n >= b:
    print(int(a*(b-1)/b) - a*int(b-1/b))
else:
    print(int(a*n/b) - a*int(n/b))

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
x=B-1/(1000*A)
if N>=B:
    print(A)
else:
    print((A*N//B)-A*(N//B))

Submission status: Wrong Answer

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

Answer = floor((A*N)/B) - (A*floor(N/B))

print(Answer)

Submission status: Wrong Answer

Solution code:

from math import floor
A, B,N = map(int,input().split())
ans = 0
for i in range(1,A):
    t = A*i//B-A*(i//B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans < t:
        ans = t
print(ans)

Submission status: Wrong Answer

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, -1):
        if res < a * i // b - a * (i // b):
            res = a * i // b - a * (i // b)
        else:
            break

    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: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, n-1, -1):
    f1 = math.floor(a*i/b)
    f2 = math.floor(i/b)
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

if n > b:
  print(int(a*(b-1)/b))
else:
  print(int(a*n/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=10000000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))

for i in range(n):
    if i>teisuu:
        break
    temp=n-i
    maxtemp=max(maxtemp,funcsum(n-i))
print(maxtemp)

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


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

Solution code:
import math
li = list(map(int, input().split()))
maxn = 0
q=li[2]
if q>li[1]:
  q=li[1]
for x in range(1, q):
    temp = 0
    a = math.floor(li[0] * x / li[1])
    b = math.floor(x / li[1])
    temp = a - a * b
    if temp > maxn:
        maxn = temp
print(maxn)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, N = [int(x) for x in input().split()]


    def f(m):
        return (A * m) // B - A * (m // B)



    l = f(1)
    e = f(N)
    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False

    ok = 1
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 5:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid


    print(max(l, e, f(ok)))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    if a == b == n == 1:
        print(0)
    elif b <= n:
        print(floor(a*n//n) - a*floor(n//n))
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

def F(x):
    return (a*x//b)-a*(x//b)

if b>=a and b>10**6:
    #print('B>=A')
    print(min(n,a-1))
else:
    ans=0
    for i in range(n+1):
        f=F(i)
        #print(f)
        if f>ans:
            #print(ans,i)
            ans=f
    
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# import bisect  # 二分探索の公式のライブラリをimportする
A, B, N = map(int, input().split())
ans = (int(A*N/B) - A*int(N/B))
# シミュレーション
for i in range(max(N-1000, 0), N+1):
    ans = max(ans, int(A*i/B)-A*int(i/B))
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
result = int(((N/B-N//B)*A)//1)
print(result)

Submission status: Wrong Answer

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

if b >= n:
    x = n
    t = int(a * x / b) - a * int(x/b)
else:
    t = int(a * n / b) - a * int(n/b)
    
print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

left, right = 0, n
while right - left > 1e-5:
  # print(left,right)
  x = mid = (left + right) / 2
  # val = a * x // b - a * (x // b)
  val = x * (a - 1) / b + 1
  if val > 0:
    left = mid
  else:
    right = mid

x = int(right)
print(a * x // b - a * (x // b))

Submission status: Wrong Answer

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

n = min(N, A-1)
print(int(A*n/B) - A*int(n/B))

Submission status: Wrong Answer

Solution code:
import math

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

if B - 1 <= N:
    x = B - 1
else:
    x = N
    print('h')

ans = math.floor(A * x / B) - A * math.floor(x / B)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
x=N
ans=math.floor(A*x/B)-A*math.floor(x/B)
print(ans)

Submission status: Wrong Answer

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

def floor(x,y):
  return int(x/y)

if b > n:
  x = n
  print(floor(a*x, b)-a*floor(x, b))
else:
  print(floor(a*b, b)-a*floor(b,b))

Submission status: Wrong Answer

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

if N >= B:
    result = A - 1
else:
    # 区間０−BをA等分
    delta = B/A
    n = int(N / delta) # 0,1,...,A-1
    result = n

print(result)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B,N = map(int,input().split())
ans = -100000000
for i in range(1,A):
    t = A*i//B-A*(i//B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans < t:
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

x = list()
for i in range(n):
  y = math.floor(a*i/b) - a*math.floor(i/b)
  x.append(y)

z = sorted(x)
print(z[-1])

Submission status: Wrong Answer

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

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

l = 0
r = n
ans = 0
if n < 100:
    for i in range(n+1):
        ans = max(ans,f(i))
i = 0
while i < 50 and r - l > 10:
    rr = (l + 2*r)//3
    ll = (2*l + r)//3
    i += 1
    if f(ll) > f(rr):
        r = rr
    elif f(ll) < f(rr):
        l = ll
    else:
        r = rr

for i in range(l,r+1):
    ans = max(ans,f(i))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,n = LI()
    if 2*b >= n:
        print(max((a*n)//b-a*(n//b),(a*(n-1))//b-a*((n-1)//b)))
        return
    ans = 0
    for x in range(b*((n-1)//b),n+1):
        ans = max(ans,(a*x)//b-a*(x//b))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
import math

if __name__ == '__main__':
    a, b, n = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    # for x in range(n+1):
    #     print(math.floor(a*x/b)-a*math.floor(x/b))

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

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    while 1:
        if (a * n) % b == 0 and n % b == 0:
            n -= 1
        else:
            break

    ans = math.floor(a * (n) / b) - a * math.floor((n) / b)

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=1000000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))

for i in range(n):
    if i>teisuu:
        break
    temp=n-i
    maxtemp=max(maxtemp,funcsum(n-i))
print(maxtemp)

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


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if(n>b-b%n+1): n -= b-b%n+1
print((a*n)//b - a*(n//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def judge(mid):
    if mid == 0:
        return True
    if (a*mid//b) - (a*(mid//b)) > (a*(mid-1)//b) - (a*((mid-1)//b)):
        return True
    else:
        return False

if judge(n):
    print((a*n//b) - (a*(n//b)))
    sys.exit()
if (a*0//b) - (a*(0//b)) > (a//b) - (a*(1//b)):
    print(0)
    sys.exit()

left = 0
right = n

while right - left > 1:
    mid = (right + left) // 2
    if judge(mid):
        left = mid
    else:
        right = mid

print((a*left//b) - (a*(left//b)))

Submission status: Wrong Answer

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


ans = (a*n)//b-a*(n//b)
ans2 = (a*(n-1))//b - a*((n-1)//b)
ans3 = (a*(n-2))//b - a*((n-2)//b)

print(max(ans,ans2,ans3))

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
x=B-1/(1000*A)
if N>=B:
    print((A*x//B)-A*(x//B))
else:
    print((A*N//B)-A*(N//B))

Submission status: Wrong Answer

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


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


print(A-1 if N >= B else f(N))

Submission status: Wrong Answer

Solution code:
from math import floor


def f(a, b, x):
    return floor(a * x / b) - a * floor(x / b)


def solve(a, b, n):
    if min(a, b) <= n:
        return min(a, b) - 1

    while f(a, b, n) == 0:
        n -= 1
    return f(a, b, n)


if __name__ == "__main__":
    a, b, n = map(int, input().split())
    print(solve(a, b, n))

Submission status: Wrong Answer

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

lo = 0
hi = N
ans = 0

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

while hi > lo :
    if f(lo) <= f(hi):
        mid = (lo + hi) // 2
        if f(mid)<=f(mid+1):
            lo = mid+1
        else:
            lo = mid
    else:
        mid = -(-(lo + hi) // 2)
        hi = mid

print(f(lo))