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())
print((a*n)//b-a*(n//b))

Submission status: Wrong Answer

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

if n%b == 0 :
    print(a*(n-1)//b - a*((n-1)//b))
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())
ans = 0
if B-1 <=  N:
  for x in range(B-1,N+1):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
    if ans == floor(A*x/B) - A*floor(x/B):
      c = x
else:
  for x in range(N):
    ans = max(ans, floor(A*x/B) - A*floor(x/B))
    if ans == floor(A*x/B) - A*floor(x/B):
      c = x
print(ans)

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(1, min(a, n)+1):
    ma = max(ma, seq(a, b, i))
print(ma)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
print(math.floor(A*N/B)-A*math.floor(N/B))

Submission status: Wrong Answer

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

x = b - 1 if b - 1 <= n else n - 1
print(a*x//b - a * (x // b))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N,1,-1):
    if i%B==0:
        continue
    else:
        ans=math.floor(A*i/B)-A*math.floor(i/B)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0
x = B
ans = max(ans, A*x//B - A*(x//B))
if B > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)

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)


    ans = max(f(1), f(N))
    high = N + 1
    low = 1
    loopn = 0
    while high - low > 1:
        loopn += 1
        if loopn >= 10 ** 5:
            break
        mid_left = int(high / 3 + low * 2 / 3)
        mid_right = int(high * 2 / 3 + low / 3)
        if f(mid_left) >= f(mid_right):
            low = mid_left
        else:
            high = mid_right

    print(max(ans, f(max(1, low - 1)), f(low), f(high), f(min(N, high + 1))))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

min_num = 1
max_num = N

def func( x ):
  return math.floor( A * x / B ) - A * math.floor( x / B )
  
ret = 0
while True:
  a = math.ceil( ( max_num + min_num ) / 2 )
  if func( max_num ) - func( min_num ):
    min_num = a
  else:
    max_num = a
  if max_num == min_num:
    break

print( func( a ))

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C0,C1,C2,C3)
    _C=max(C0,C1,C2,C3)
    if C0==C1==C2==C3:
        print(unko)

    if C0==_C:
        ed=mid2
    elif C1==_C:
        ed=mid2
    elif C2==_C:
        st=mid1
    elif C3==_C:
        st=mid1

if ed-st==2:
    C=max(main(st),main(st+1),main(ed),C)
print(C)

Submission status: Wrong Answer

Solution code:
import math

def factor(N):
    ans = []
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

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

b = factor(B-1)
bb = factor(B)
a = factor(A)
aa = factor(A-1)
ans = -1e9
for i in b:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in bb:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in a:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in aa:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    a, b, n = map(int, input().split())
    if b > n:
        print(int(math.floor(a*n/b)-a*math.floor(n/b)))
        exit()

    if b >= 10**6:
        ans = 0
        for i in (b-1, n+1, b):
            temp =  math.floor(a*i/b)-a*math.floor(i/b)
            if ans < temp:
                ans = temp
        print(int(ans))
        exit()

    ans = int(math.floor(a*n/b)-a*math.floor(n/b))
    i = math.floor(n/b)*b-1
    for _ in range(10**6):
        temp =  math.floor(a*i/b)-a*math.floor(i/b)
        if ans < temp:
            ans = temp
        i -= b
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
X = 3

print(math.floor(A*N/B)-A*math.floor(X/B))

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 + 1
ans = 0
if n < 100:
    for i in range(n+1):
        ans = max(ans,f(i))

i = 0
while i < 50:
    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())


tmp = n // b * b - 1
ans = max(int(a * tmp / b) - a * int(tmp / b), int(a *n / b) - a * int(n / b))

print(ans)

Submission status: Wrong Answer

Solution code:
# abc165_d.py
from math import floor
A, B,N = map(int,input().split())
ans = 0
for i in range(1,A+1):
    t = floor(A*i/B)-A*floor(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:
from math import floor
A,B,N  = map(int,input().split())
# num = 0
# for x in range(0,N+1)[::-1]:
#     tmp = floor((A*x)/B) - (A * floor(x/B))
#     if num < tmp:
#         num = tmp
# print(num)
print(floor((A*N)/B) - (A * floor(N/B)))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
a1=int(a*n/b)-a*int(n/b)
i=int((n+1)/b)
if i!=0:
    a2=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
    print(max(a1,a2))
else:
    print(a1)

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C0,C1,C2,C3)
    _C=max(C0,C1,C2,C3)
    if C0==C1==C2==C3:
        st+=1
        ed-=1
        continue

    if C0==_C:
        ed=mid2
    elif C1==_C:
        ed=mid2
    elif C2==_C:
        st=mid1
    elif C3==_C:
        st=mid1

if ed-st==2:
    C=max(main(st),main(st+1),main(ed),C)
print(C)

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = map(int, input().split())
    n=0
    if N < B:
        print(int(A*N/B))
    else:
        for i in range(B+1,N+1):
            if n == int(A*i/B) - A*int(i/B):
                break
            elif n < int(A*i/B) - A*int(i/B):
                n = int(A*i/B) - A*int(i/B)
        print(n)
        
main()

Submission status: Wrong Answer

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

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


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

high = n
low = 0
while high - low > 0.000000001:
    print(high, low)
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) <= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(f(int(high)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
D = N // B
ans = []
x1 = N
x2 = B*D-1
if x2 < 0:
    x2 =0
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)

print(max(f(x1), f(x2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans)

Submission status: Wrong Answer

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

ans = (A*N)//B - (A * (N//B))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

delta = 1.0*B/A

if N >= A- delta:
    print(A-int(delta)-1)
else:
    print(int(N/delta))

Submission status: Wrong Answer

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    A,B,N = isRaw()
    a1 = int((A*N)/B)-A*int(N/B)
    a2 = 0
    if N>=B-1:
        res = ((N+1)//B)*B-1
        a2 = int((A*res)/B)-A*int(res/B)
    
    return max(a1,a2)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split(" "))
max_floor = 0
for x in range(N):
  floor_x = int(A*x/B) -A*int(x/B)
  if max_floor < floor_x:
    max_floor = floor_x
print(floor_x)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    a, b, n = map(int, input().split())
    if b > n:
        print(int(math.floor(a*n/b)-a*math.floor(n/b)))
        exit()

    if b >= 10**6:
        ans = 0
        for i in (b-1, n+1, b):
            temp =  math.floor(a*i/b)-a*math.floor(i/b)
            if ans < temp:
                ans = temp
        print(int(ans))
        exit()

    ans = int(math.floor(a*n/b)-a*math.floor(n/b))
    i = math.floor(n/b)*b-1
    for _ in range(10**6):
        temp =  math.floor(a*i/b)-a*math.floor(i/b)
        if ans < temp:
            ans = temp
    print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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


if N < B:
    x = N
elif N == B:
    x = N
elif N > B:
    x = B - 1


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

Submission status: Wrong Answer

Solution code:

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0
x = B
ans = max(ans, A*x//B - A*(x//B))
if N > 1:
    x -= 1
    ans = max(ans, A*x//B - A*(x//B))

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if B==1:
    print(0)
    exit()

if N==1:
    ans=(A//B)-A*(1//B)
    print(ans)
    exit()

if B<N:
    val=B-1
    ans=(A*val)//B
else:
    val=N 
    ans=(A*val)//B

print(ans)

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 n == 1:
        print(floor(a//b))
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = map(int, input().split())
x = n
y = max(0, b * (n // b) - 1)
ansx = floor(a*x/b) - a*floor(x/b)
ansy = floor(a*y/b) - a*floor(y/b)
print(max(ansx, ansy))

Submission status: Wrong Answer

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

#for x in range(n+1):
x=b-1 if n>b else n-1
ans=int(a*x/b)-a*int(x/b)
print(ans)

Submission status: Wrong Answer

Solution code:
# abc165_d.py
from math import floor
A, B,N = map(int,input().split())
ans = 0
for i in range(1,A):
    t = floor(A*i/B)-A*floor(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())

if n%b == 0 :
    print(a*(n-1)//b)
else:
    print(a*(n)//b - a*((n)//b))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
a, b, n = map(int, input().split())
print(math.floor((a * n) / b) - a * math.floor(n / b))

Submission status: Wrong Answer

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

left = -1
right = N
def check(x):
    global A, B
    return math.floor(A * x / B) - A * math.floor(x / B)

if B == N:
    print(check(N - 1))
else:
    print(check(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n, max(-1, n - a - 1), -1):
    ans = max(ans, a * x // b - a * (x // b))

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = [0]*(min(N, B, A))
#print('len: ', len(l))


for x in range(1, len(l) + 1):
    l[x-1] = ((A*x)//B) - A*(x//B)

print(max(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = (int(x) for x in input().split())
print(n-(a-b)+1)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
t = N//B
if N % B == 0:
    a = max(1,N-1)
    b = N
else:
    a = max(1,t*B - 1)
    b = N

print(max(math.floor(A*a/B)-A*math.floor(a/B),math.floor(A*b/B)-A*math.floor(b/B)))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

if b == 1:
    print(0)
    exit()
if n < b:
    print((a*n//b) + a*(n//b))
else:
    print(a-1)

Submission status: Wrong Answer

Solution code:
import math
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(li)
print(max(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -10 ** 18
for x in range(n, max(-1, n - a), -1):
    ans = max(ans, a * x // b- a * (x // b))
print(ans)

Submission status: Wrong Answer

Solution code:
def naive(a, b, n):
	ans = 0
	for i in range(1, n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

def main(a, b, n):
	ans = 0
	tmp = []
	for i in range(max(n + 1 - a * 10 - 1, 1), n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans


n = 10000
for a in range(1, 10):
	for b in range(1, 100):
		if naive(a, b, n) != main(a, b, n):
			print(a, b, naive(a, b, n), main(a, b, n))

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

Submission status: Wrong Answer

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

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-1))
else:
    print(func(N))

Submission status: Wrong Answer

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

if b == 0:
    print(0)
    exit()
if n < b:
    print((a*n//b) + a*(n//b))
else:
    print(a-1)

Submission status: Wrong Answer

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

max_ = (A*0)//B - A * (0//B)

for num in range(N//B+1, N//B + 2):
  #print(num)
  num1 = num * B -1
  if num1 > N:
    num1 = N
  #print(num1)
  ans = (A*num1)//B - A * (num1//B)
  #print(ans)
  #print()
  if ans > max_:
    max_ = ans
print(max_)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import random
import copy
import math
def main():
     A,B,N = map(int,input().split())
     if N < B:
          x = min(B,N)-0.000000001
          ma = math.floor(A*x/B)-A*math.floor(x/B)
          x = N
          ma = max(ma,math.floor(A*x/B)-A*math.floor(x/B))
     else:
          ma = A-1
     print(ma)
                    
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

for i in range(b):
    j = b - i
    if j > n:
        pass
    elif f(a, b, j) > max:
        max = f(a, b, j)
        break

print(max)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
m = -float('inf')
for i in range(n + 1):
    t = int(a * i / b) - a * int(i / b)
    if t > m:
        m = t
print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,n = LI()
print(a * min(n,b) // b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if (a - 1) * b <= a * n:
    print(a - 1)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C0,C1,C2,C3)
    _C=max(C0,C1,C2,C3)
    if C0==_C:
        ed=mid2
    elif C1==_C:
        ed=mid2
    elif C2==_C:
        st=mid1
    elif C3==_C:
        st=mid1
    
if ed-st==2:
    C=max(main(st),main(st+1),main(ed),C)
print(C)

Submission status: Wrong Answer

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

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

t1 = f(a, b, n)
t2 = f(a, b, n - n%b - 1)
t = max(t1, t2)

print(t)

Submission status: Wrong Answer

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

print(int(A * (B - 1) / B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
a,b,n=I()
ans=0
temp=min(n,b)
print(mt.floor((a*temp)/b))

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
 
ans = 0
for i in range(n+1):
  t = int(a * i / b) - a * int(i/b)
  print(t)
  if t > ans:
    ans = t
 
print(int(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 range(1, N+1):
  #print(i)
  #temp = math.floor(A * i / B) - A * math.floor(i / B)
  #print(temp)
  #if temp > ret:
    #ret = temp

temp = math.floor(A * N / B) - A * math.floor(N / B)
if temp > ret:
  ret = temp

  
print(ret)

Submission status: Wrong Answer

Solution code:

s = input().split()
a = int(s[0])
b = int(s[1])
n = int(s[2])

l = list()

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

print(l)
print(max(l))

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:
  ans1 = floor(a*n, b)-a*floor(n, b)
  x = n
  while True:
    if x%b == 0:
      break
    x -= 1
  ans2= floor(a*x, b)-a*floor(x, b)
  print(max(ans1,ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
if B==1 or A==1:
    print(0)
    exit()
while True:
    if N%B!=0:
        print(math.floor(A*N/B)-(A*math.floor(N/B)))
        break
    elif N==0:
        print(0)
        break
    else:
        N-=1

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
if B >= N:
    res = int(A*N/B)-A*int(N/B)
else:
    while N%B != 0:
        N -= 1
    N -= 1
    res = int(A*N/B)-A*int(N/B)
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = map(int, input().split())
def flr(X):
    return floor(a * X / b) - a * floor(X / b)
if b <= n:
    print(flr(b))
else:
    print(flr(n))

Submission status: Wrong Answer

Solution code:
import math 

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

Submission status: Wrong Answer

Solution code:
def naive(a, b, n):
	ans = 0
	for i in range(1, n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

def main(a, b, n):
	ans = 0
	tmp = []
	for i in range(max(n + 1 - a * 10 - 1, 1), n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

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

Submission status: Wrong Answer

Solution code:
#D - Floor Function
A,B,N = map(int, input().split())

a = (A*N)//B
b = N//B
print(a-A*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -10 ** 18
for x in range(n, max(-1, n - a), -1):
    ans = max(ans, a * x // b, a * (x // b))
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  import math
  a, b, n = map(int, input().split())
  gcd = math.gcd(a, b)
  a = int(a / gcd)
  b = int(b / gcd)
  ans = 0
  for i in range(min(b+1, n+1)):
    tmp = math.floor(a*i/b) - a*math.floor(i/b)
    if tmp > ans:
      ans = int(tmp)
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a,b,n= list(map(int, input().split()))
ma=0
for i in range(1000000):
    ma=max((a*i/b)//1-a*((i/b)//1),ma)
    ma=max((a*(n-i)/b)//1-a*(((n-i)/b)//1),ma)
print(int(ma))

Submission status: Wrong Answer

Solution code:
from math import floor

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

Submission status: Wrong Answer

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
while True:
    i+=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: Wrong Answer

Solution code:
import math


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


#math.floor(

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 + 1

i = 0
while i < 50:
    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

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