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:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    for n in range(N, B):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
 
import itertools
import heapq
#import bisect
 
import copy
from functools import lru_cache
 
def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
 
def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta
 
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
 
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
 
def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)
 
 
def main():
    a,b,n=map(int,input().split())
    def fl(a,b,x):
        return int(a*x/b)-a*int(x/b)
    x=n
    pretemp=fl(a,b,x)
    prex=0
    nowmax=n
    nowmin=0
    dis=n//2
    if dis<=0:
        dis=1
    i=1
    right=False
    while i<=500000:
        if i%10==0:
            dis=-(dis//(-1.3))
        if right:
            x+=dis
            if x>n:
                x=n
            temp=fl(a,b,x)
        else:
            x-=dis
            if x<0:
                x=0
            temp=fl(a,b,x)
        if temp>=pretemp:
            pass
        elif temp<pretemp:
            right=(right-1)*(-1)
        pretemp=temp
        i+=1
    if x+1<=n:
        tempup=fl(a,b,x+1)
    else:
        tempup=fl(a,b,x)
    if x-1>=0:
        templow=fl(a,b,x-1)
    else:
        templow=fl(a,b,x)
    temp=fl(a,b,x)
    temp=max(temp,templow,tempup)
 
    print(temp)
 
 
if __name__ == "__main__":
 
    main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
s=math.floor((A*B-1)/B)
t=math.floor((A*N)/B)
print(max(s,t))

Submission status: Wrong Answer

Solution code:
import math

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


y = math.floor(a*(b-1)/b) - a*math.floor((b-1)/b)

y = max(math.floor(a*n/b) - a*math.floor(n/b), y)
print(int(y))

Submission status: Wrong Answer

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

ans=0
for i in range(b,max(b-3,-1),-1):
    ans=max(ans,((a*i)//b-(a*(i//b))))
print(ans)

Submission status: Wrong Answer

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


y = int(a*(b-1)/b) - a*int((b-1)/b)

y = max(int(a*n/b) - a*int(n/b), y)
print(int(y))

Submission status: Wrong Answer

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


y = int(a*(b-1)/b) - a*int((b-1)/b)

y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    mi = math.floor(B / N)+math.floor(A / N)
    for n in range(N-mi, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    mi = math.floor(A / N)
    for n in range(N-mi, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, N = il()
    ret = 0
    mi = math.floor(B / N)
    for n in range(N-mi, N + 1):
        ret = max(ret, f(A, B, n))
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

x = int((n+1-b)/b)


y = int(a*(x*b-1)/b) - a*int((x*b-1)/b)
y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
a, b, n = int(arr[0]), int(arr[1]), int(arr[2])
if b<=n:
   k = int((a*(b-1))/b)
else:
   k = int((a*n)/b)

Submission status: Wrong Answer

Solution code:
#n = int(input())
n,m,k = [int(e) for e in input().split()]
#print(n,m,k)
#q = []
#for i in range(k):
#  el = input().split()
#  q.append(el)
#
#print(q)
mx = 0
wk = n
if m < k:
  k = m
for i in range(1,k+1):
  a = (wk * i ) // m
  if mx < a :
    mx = a
print(mx)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m,k = [int(e) for e in input().split()]
mx = 0
wk = n
for i in range(1,k+1):
  a = (wk * i ) // m
  if mx < a :
    mx = a
print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
a, b, n = int(arr[0]), int(arr[1]), int(arr[2])
if b<=n:
   k = int((a*n)/b)
else:
   k = int((a*n)/b)

Submission status: Wrong Answer

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)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
A,B,N = [int(x) for x in input().split()]
print(min(B-1,N));

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 = list(map(int, input().split()))
x = b-1
t = int(a*x//b) -a*int(x//b)


print(t)

Submission status: Wrong Answer

Solution code:
a,b,n = list(map(int, input().split()))
x = b-1
t = int(a*x/b) -a*int(x/b)


print(t)

Submission status: Wrong Answer

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

ans1 = (a*n)//b - a*(n//b)
ans2 = (a*(b-1))//b - a*((b-1)//b)

print(max(ans1,ans2))

Submission status: Wrong Answer

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

ans1 = (a*n)//b - a*(n//b)
ans2 = (a*b-1)//b - a*(b-1//b)

print(max(ans1,ans2))

Submission status: Wrong Answer

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

ans = 0
for x in range(B):
  A_x = A * x
  left_ = int(A_x / B)
  right_ = A * int(x / B)
  fnc_ = left_ - right_
  if fnc_ <= N:
    ans = max(ans, fnc_)
    # print("入れ替わりans", ans)

  # print("     x", x)
  # print(" left_", left_)
  # print("right_", right_)
  # print("  fnc_", left_ - right_)


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = list(map(int, input().split()))
minx = min([B-1, N])
print(math.floor(A*minx/B) - A*math.floor(minx*B))

Submission status: Wrong Answer

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


x = 0

if N >= B - 1:
    x = B - 1
elif N < B -1:
    x = N
    if not N % B == 0:
        pass
    else:
        x -= 1


yoshiki = np.floor((A*x) / B) - A * np.floor(x/B)
print(yoshiki)

Submission status: Wrong Answer

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

ans=0
while N:
    if ans<=A*N//B-A*(N//B):
        ans=A*N//B-A*(N//B)
    else:
        break
    N-=1

print(ans)

Submission status: Wrong Answer

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


x = 0

if N >= B - 1:
    x = B - 1
elif N < B -1:
    x = N
    if not N % B == 0:
        pass
    else:
        x -= 1


yoshiki = np.floor(A*x / B) - A * np.floor(x/B)
print(yoshiki)

Submission status: Wrong Answer

Solution code:
from math import floor

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

ans=0
for x in range(a):
    ff=floor(a*x/b)-a*floor(x/b)
    ans=max(ans,ff)
print(ans)

Submission status: Wrong Answer

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




if N >= B - 1:
    x = B - 1
else:# N < B -1 :
    x = N


yoshiki = np.floor(A*x / B) - A * np.floor(x/B)
print(yoshiki)

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:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    ans = int(a*n/b) - a*int(n/b)
    ans = max(ans,int(a*(b-1)/b) - a*int((b-1)/b))
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
ans = 0
if N<10**6:
    for i in range(N+1):
        tmp = math.floor(A*i/B)-A*math.floor(i/B)
        if tmp>ans:
            ans = tmp
elif N>=10**6 and N>=B:
    ans = math.floor(A)
elif N>=10**6 and N<B:
    ans = math.floor(A*N/B)-A*math.floor(N/B)
    

print(ans)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
ans = 0
if N<10**5:
    for i in range(N+1):
        tmp = math.floor(A*i/B)-A*math.floor(i/B)
        if tmp>ans:
            ans = tmp
elif N>=10**6 and N>=B:
    ans = math.floor(A)
elif N>=10**6 and N<B:
    ans = math.floor(A*N/B)-A*math.floor(N/B)
    

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

x = 1

while True:
    if x > N:
        break
    if A <= res:
        break
    else:
        res = int(A*x/B)- A* int(x/B)
    x += 1

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
def calc(x):
    return int(a*x/b)-a*int(x/b)
print(calc(min(b,n)))

Submission status: Wrong Answer

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

for x in range(1,N+1):
    if A <= res:
        continue
    else:
        res = int(A*x/B)- A* int(x/B)

print(res)

Submission status: Wrong Answer

Solution code:
import math

A,B,N=map(int,input().split())
print(math.floor(A/B*(~-B/B if N//B>0 else N)))

Submission status: Wrong Answer

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

x = (n//b)*b-1

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

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:
import sys
a,b,n = map(int,input().split())
for i in range(n+1):
    c = int(a*i/b)-a*int(i/b)
    if i == 0:
        d = c
    else:
        if c > d:
            d = c
        else:
            print(d)
            sys.exit()
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(f)

Submission status: Wrong Answer

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

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

ans = floor(max(b-1,n))

print(int(ans))

Submission status: Wrong Answer

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

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

ans = max(floor(b-1),floor(n))

print(int(ans))

Submission status: Wrong Answer

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

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

ans = max(floor(b-1),floor(n))

print(ans)

Submission status: Wrong Answer

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

    if B == 1:
        ans = 0
        print(ans)
        return

    if B >= N:
        x = N
    else:
        x = B-1

    ans = (A*x) // B
    print(ans)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = f(min(n,b-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Nlist = list(map(int, input().split()))

A = Nlist[0]; B = Nlist[1]; N = Nlist[2]

print(int(A*(N%B)/B))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
ans = -float('inf')

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, raw_input().split(' '))
m = 0
print min(b,n) * a /b
"""
for t in range(0, min(b,n) + 1):
	print t*a/b
	m = max(m,t * a / b)
	#print int(t * a / b)
print m
"""

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, raw_input().split(' '))
m = 0
for t in range(0, min(b,n) + 1):
	m = max(m,t * a / b)
	#print int(t * a / b)
print m

Submission status: Wrong Answer

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

p = [int(math.floor(a*i/b) - a*math.floor(i/b)) for i in{n, n-1}]

print(max(p))

Submission status: Wrong Answer

Solution code:
import math
a, b, i = map(int, input().split())
q = []
p = math.floor(a*i/b) - a*math.floor(i/b)
q.append(int(p))
print(max(q))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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())
print(A * min(B, N) // B)

Submission status: Wrong Answer

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

X = N
Y = min(B-1,N)

out1 = int(A*X/B) - A*int(X/B)
out2 = int(A*Y/B) - A*int(Y/B)
print(max(out1,out2))

Submission status: Wrong Answer

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

X = N
Y = min(B-1,N)

out1 = A*X//B - A*(X//B)
out2 = A*Y//B - A*(Y//B)
print(min(out1,out2))

Submission status: Wrong Answer

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

X = N
Y = min(B-1,N)

out1 = int(A*X/B) - A*int(X/B)
out2 = int(A*Y/B) - A*int(Y/B)
print(min(out1,out2))

Submission status: Wrong Answer

Solution code:
import math
 
a,b,n = map(int,input().split())
 
ans = 0
pre = 0
for i in range(1, n+1):
  now = math.floor(a*i / b) - a * math.floor(i / b)
  if now > pre:
    ans = i
    pre = now
  elif not now == 0:
    break
    
print(pre)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor
from collections import deque

def main():
    A,B,N=map(int,input().split())
    
    ans1=min(N,B)
    ans2=floor(A*ans1/B)-A*floor(ans1/B)
    print(ans2)
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from pprint import pprint
 
A, B, N = map(int, sys.stdin.readline().strip().split())
 
def func(x):
    return A*x//B - A*(x//B)
 
 
right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    if mid_left == mid_right:
        break
    # print("func", func(mid_left), func(mid_right))
    if func(mid_left) < func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)
 
ans = -1 * float("inf")
for i in range(left, right+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from pprint import pprint

A, B, N = map(int, sys.stdin.readline().strip().split())

def func(x):
    # return math.floor(A*x/B) - A*math.floor(x/B)
    return int(A*x/B) - A*int(x/B)


right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    #if mid_left == mid_right:
    #    break
    # print("func", func(mid_left), func(mid_right))
    if func(mid_left) <= func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)

ans = -1 * float("inf")
for i in range(left, right+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
 
ans1 = int((A*N)/B)-A*(N/B)
 
if B-1<=N:
	ans2 = (A*(B-1))//B
else:
  	ans2=0
 
print(max(ans1,ans2))

Submission status: Wrong Answer

Solution code:
from sys import stdin
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
 
ans1 = int((A*N)/B)-A*int(N/B)
 
if B-1<=N:
	ans2 = (A*(B-1))//B
else:
  	ans2=0
 
print(max(ans1,ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
if not (1 <= A <= 10 ** 6):
    1 // 0
if not (1 <= B <= 10 ** 12):
    1 // 0
if not (1 <= N <= 10 ** 12):
    1 // 0

Submission status: Wrong Answer

Solution code:
from sys import stdin

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]

ans1 = int((A*N)/B)-A*int(N/B)

if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
 
print(max(ans1,ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0

print(max(ans,ans2))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0

print(ans2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
    
if ans>=ans2:
  print(ans)
else:
  print(ans2)

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
    
 
if ans>=ans2:
  print(ans)
else:
  print(ans2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
    
 
 
print(ans2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
 
A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if B-1<=N:
	ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
  	ans2=0
    
 
 
print(max(ans, ans2))

Submission status: Wrong Answer

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

if b == 1 or a == 1:
    print(0)
else:
    r = min(b-1, n) 
    s = (a * r) // b - a * (r // b)
    print(r)

Submission status: Wrong Answer

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