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 = (int(x) for x in input().split())
x = int(N/2)
ans = -1
length = int(N/4)
if(N <= 12):
    for i in range(N+1):
        if (int(A*i/B) - A*int(i/B)) > ans: 
             ans = (int(A*i/B) - A*int(i/B))
while(x > 2 and length > 2):
    ans1 = int(A*x/B) - A*int(x/B)
    ans2 = int(A*(x+1)/B) - A*int((x+1)/B)
    if(x == N):
        if(ans1 > ans):
            ans = ans1
        break
    elif(ans1 > ans2 and ans1 > ans):
        ans = ans1 
        x = ans -length
    elif(ans2 > ans1 and ans2 > ans):
        ans = ans2
        x = ans + length
    elif(ans1 > ans2 and ans1 <= ans):
        x = ans - length
    elif(ans1 < ans2 and ans2 <= ans):
        x = ans + length
    length = int(length/2)
for i in range(max(0,x-2*length),min(N,x+2*length)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
for i in range(min(6,N)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

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

if A < B:
    if B//2 < N:
        x = B//2
    else:
        x = N
else:
    if B < N:
        x = B-1
    else:
        x = N
m = math.floor(A*x/B)-A*math.floor(x/B)
print(m)
# m = -float("inf")

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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


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


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

    ans = 0

    low = 1
    high = N

    while abs(low - high) != 1:
        #print(low, high)
        mid = (high + low) // 2
        tmp = fs(A, B, mid)
        if tmp > ans:
            ans = tmp
            low = mid
        else:
            high = mid

    print(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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):
		return max(val(a, b, n), val(a, b, max((n // b) * b - 1, 1)), val(a, b, n - 1))

# n = 100
# for a in range(1, 100):
# 	for b in range(1, 1000):
# 		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:
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 - 0.001))
else:
    print(flr(n))

Submission status: Wrong Answer

Solution code:
import math

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

ans = -10**13
if N == max(A, B, N):
    ans = math.floor((A*N)/B)-A*(N//B)
else:
    if N <= 1000000:
        for x in range(1, N+1):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(1, 300000):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)

        base = N//2-150000
        for x in range(base, base+300000):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)

        for x in range(N-300000, N+1):
            tmp = math.floor((A*x/B))-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

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

x = None
if N < B:
    x = N
else:
    x = B
    max_diff = 0
    for _x in range(B, N + 1):
        diff = (x / B) - floor(x / B)
        if max_diff <= diff:
            max_diff = diff
            x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
x = math.floor(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())
if (B<N):
    print(A*N//B)
else:
    c=(A*N)//B-A*(N//B)
    d=(A*B)//B-A
    e=A//B
    print(max(c,d,e))

Submission status: Wrong Answer

Solution code:
import numpy as np
import pprint

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

ans = 0
if b > n:
    ans = ((a * n) // b) - (a * (n // b))
else:
    ans = ((a * b) // b) - (a * (b // b))

print(ans)

Submission status: Wrong Answer

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

tmp = (N // B) * B - 1

tmp1 = int(A * tmp / B) - A * int(tmp / B)
tmp2 = int(A * N / B) - A * int(N / B)

print(max(tmp1, tmp2))

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)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(1, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R >= maxR:
        maxR = R
        maxX = x
print (maxX)

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a, b, n = map(int, input().split())
    l = 1
    r = n
    ans = 0
    x = n
    for z in range(1000):
        t = math.floor(a*x/b) - a*math.floor(x/b)
        if ans <= t:
            ans = t
            r = x
        else:
            l = x
        x = (l+r)//2

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
 
L = []
 
if N >= 100000:
  for i in range(100000):
    r = (N-i+1)/B
    L.append(int(A*r)-A*int(r))
else:
  for i in range(N):
  	r = (i+1)/B
  	L.append(int(A*r)-A*int(r))
 
print(max(L))

Submission status: Wrong Answer

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

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

print(ret)

Submission status: Wrong Answer

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

x = 0
x_per_b = 0
d = 1 / b
for x in range( min( b, n ) + 1 ):
    f_x = int( a * x_per_b ) - a * int( x_per_b )
    if x == 0 or f_max < f_x:
        f_max = f_x
    x_per_b = x_per_b + d

print( f_max )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
ans = []
for t in range(B):
    x = t+1
    ansX = A*x//B-A*(x//B)
    ans.append(ansX)
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 = a
else:
  k = (a*n)//b
print(k)

Submission status: Wrong Answer

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

max_s = []
j = 0
for i in range(n,0,-1):
    j += 1
    if j == 100:
        break
    else:
        num = int((a*i)/b) - a*int(i/b)
        max_s.append(num)
print(max(max_s))

Submission status: Wrong Answer

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

def f2(a, b, x):
  return a * f1(1, b, x)

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

if n < b:
  result = f1(a, b, n)
else:
  for x in range(b, n + 1):
    ans = f1(a, b, x)-f2(a, b, x)
    if ans > result:
      result = ans

print(result)

Submission status: Wrong Answer

Solution code:

A,B,N=map(int,input().split())
x=N-1
max=round(x*(A/B))-A*round(x/B)
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
pp =False
t =0
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if tmp != 0:
        pp =True
    if tmp == 0:
        if sec ==True and pp ==True:
            break
        elif pp ==False and sec ==True:
            t = max(math.ceil(B/2)-1,N)
            maxn = math.floor((A*t)/B)-A*(math.floor(t/B))
            break
        sec =True
    
print(maxn)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 8: 
    for i in range(0,1000000):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
    for i in range(N-10**6,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
print(floor(maxi))

Submission status: Wrong Answer

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

n = N//B

for i in range(n+1):
  x = i*B - 1
  Y = (A*x)//B-A*(x//B)
  a.append(Y)

Y = (A*N)//B
a.append(Y)

answer = max(a)

print(answer)

Submission status: Wrong Answer

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

if b < n:
  x = b-1
else:
  x = n

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

Submission status: Wrong Answer

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

def fl(i):
  return ((A * i) // B) - (A * (i // B))

i = 1
j = [0, N]
while i > 0:
  s = fl(j[0])
  t = fl(j[1])
  if t > s:
    j[0] = (j[1] - j[0]) / 2 + j[0]
  else:
    j[1] = (j[1] - j[0]) / 2 + j[0]
    
  if j[1] - j[0] < 0.1:
    break

x = int(fl(j[0] // 1))
y = int(fl(j[1] // 1))
z = int(fl(min(j[1] // 1 + 1, N)))
print(max(x, y, z))

Submission status: Wrong Answer

Solution code:
import math


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


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

left = 0
right = N

while right - left > 1:
    mid = (left + right) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))

Submission status: Wrong Answer

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

k = (N+1)//B

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

Submission status: Wrong Answer

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

for i in range(0, 100):
  n = n - i
  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())
if a>b:
    print(n)
elif a<b:
    print(n//2)
else:
    print(1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

ans = 0
for x in range(n, n+1):
  ans = max(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 = N
for x in reversed(range(1,N+1)):
  if x % B != 0:
    print(int(A*x/B)-A*int(x/B))
    exit()

    
print(1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def fun(a, b, p):
    if ((b * p <= a * n) and (int(b * p + b - 1) // a - int(b * p - 1) // a > 0)):
        return (1)
    else:
        return(0)


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

if (b == 1):
    print(1)
    exit()

mn = 0
mx = a + 1
ok = 0
while 1:
    if mn == mx:
        if fun(a, b, mx):
            print(mx)
        else:
            print(mx-1)
        exit()
    p = (mn + mx) // 2
    # print(mn, p, mx, "#", b*p, a*n, b*p+b, "#",int(b * p + b-1) // a, int(b * p - 1) // a, int(b * p + b-1) // a - int(b * p - 1) // a)

    if fun(a, b, p):
        mn = p+1
    else:
        mx = p - 1

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)

high = N
low = 1
while high - low > 1:
    mid_left = high / 3 + low * 2 / 3
    mid_right = high * 2 / 3 + low / 3
    # print(mid_left, mid_right)
    if f(mid_left) >= f(mid_right):
        high = mid_right
    else:
        low = mid_left
print(f(high))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
if x2 < 0:
    x2 =0
ans =[0]

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

for k in range(x2, min(N, x2+A)+1):
    ans.append(f(k))
for k in range(N, max(N-A-1,0), -1):
    ans.append(f(k))


print(max(ans))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
#1 <= x <= n
#minimize  int(x/b)
#x = int(a*x/b) - a * int(x/b)
k = n%b
init = 0
for i in range(n-k, n+1):
   kouho = int(a*i/b) - a * int(i/b)
   if kouho > init:
      init = kouho
print(kouho)

Submission status: Wrong Answer

Solution code:


a,b,n = map(int,input().split())
ans = 0
round=lambda x:(x*2+1)//2
# for i in range(n+1,n-2*a,-1):
for i in range(2*a):
    ans = max(ans,round((a*i)/b) - a * round(i/b))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
for i in range(n,-1,-1):
    ans = ((a*i)//b)-(a*(i//b))
    al.append(ans)
    if len(al) > 1:
        if al[-1] <= al[-2]:
            break
print(max(al))

Submission status: Wrong Answer

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

L = []

if N >= 10:
  for i in range(10):
    r = (N-i+1)/B
    L.append(int(A*r)-A*int(r))
else:
  for i in range(N):
  	r = (i+1)/B
  	L.append(int(A*r)-A*int(r))

print(max(L))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def main():
    A, B, N = map(int, input().split())
    max = ((A*N)//B) - (A * (N//B))

    if B>=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max > temp:
            max = temp
    
    NN = N - A -1
    if NN < 0:
        NN = 0
    for index in (NN,N):
        temp = ((A*index)//B) - (A * (index//B))
        if max > temp:
            max = temp


    print(max)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    a,b,n  = map(int, input().split())
    maemax=math.floor(a*n/b)
    ushiromax=math.floor(n/b)
    if maemax*b%a==0:
        i=int(maemax*b/a)-1
    else:
        i=math.floor(maemax*b/a)-1
    j=ushiromax*b-1
    if j<=i:
        print(maemax-a*ushiromax)
    else:
        print(math.floor(j*a/b)-a*math.floor(j/b))
resolve()

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

n = min(n, b)


mem = {}
m = 0
for x in range(1, n + 1):
    if mem.get(((a * x) % b, x % b)) is not None:
        break    
    else:
        c = math.floor(a * x / b) - a * math.floor(x / b)
        mem[((a * x) % b, x % b)] = c
        m = max(m, c)
print(c)

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)


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

l = 0  # 最初の下界
r = N+1  # 最初の上界
ans = 0
while r - l > 1:  # rとlが交わることがあれば終了
    mid = (l+r) // 2  # 中央値, 選ぶ候補になっている値
    tmp = int(A*mid/B) - A*int(mid/B)
    if tmp >= ans:
        ans = tmp
        l = mid  # 下界をあげる
    else:
        r = mid  # 上界を下げる
    # print(l, r)
# print(l, r)
ans = max(ans, int(A*min(N, B-1)/B)-A*int(min(N, B-1)/B))
print(max(ans, int(A*N/B)-A*int(N/B), int(A*l/B)-A*int(l/B), int(A*min(N, r)/B)-A*int(min(N, r)/B)))

Submission status: Wrong Answer

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


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


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

    ans = 0

    low = 1
    if N % 2 == 0:
        high = N
    else:
        high = N + 1

    while abs(low - high) != 1:
        #print(low, high)
        mid = (high + low) // 2
        tmp = fs(A, B, mid)
        if tmp > ans:
            ans = tmp
            low = mid
        else:
            high = mid

    print(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n >= b:
  print(a-1)
else:
  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())
x = math.floor(n)
ans = math.floor(a * x//b)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

a,b,n = map(int, input().split())
i = min(n,b)
print(floor(a*i/b) - a*floor(i/b))

Submission status: Wrong Answer

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

if n >= b+((b-a)/a):
  ans = (a*(b+((b-a)/a)))//b - a*((b+((b-a)/a))//b)
  print(ans)
  quit()

ans = (a*n)//b - a*(n//b)

print(ans)

Submission status: Wrong Answer

Solution code:
#abc165_d.py
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])

Max = 0
y = 0

i = B - 1
while( i <= N ):
    if ( (i % B) * A - (A * i) % B ) > Max:
        Max = ((i % B) * A - (A * i) % B) // B


    i += B


if ( (N % B) * A - (A * N) % B ) > Max:
    Max = ((N % B) * A - (A * N) % B) // B


print(Max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while True:
    num=int(A*i/B)-A*int(i/B)
    if max_num<=num:
        acc+=4
        i+=acc
        max_num=num
    else:
        i-=acc
        for j in range(i):
            num=int(A*j/B)-A*int(j/B)
            if max_num<=num:
                max_num=num
            else:
                break
        break
    
print(max_num)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = a//b - a*(1//b)
for i in range(n,max(0,n-2*(int(math.sqrt(n)+1))),-1):
    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())
def f(x):
    return math.floor(a * x / b) - a * math.floor(x / b)

left, right = 0, n
while right > left + 10:
    mid1 = (right * 2 + left) / 3
    mid2 = (right + left * 2) / 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(int(left), int(right) + 1):
    listalt.append(f(i))
listalt.append(f(0))
listalt.append(f(n))
print(max(listalt))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
for i in range(n,-1,-1):
    ans = ((a*i)//b)-(a*(i//b))
    al.append(ans)
    if len(al) > 1:
        if al[-1] < al[-2]:
            break
print(max(al))

Submission status: Wrong Answer

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 8: 
    for i in range(0,1000000):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
    for i in range(N-10**6,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi,0)
print(maxi)

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 math

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

var = N//B
ans = 0
if var != 0:
    count = 0
    for i in range(N, -1, -B):
        tmp = math.floor(A*i/B) - A*math.floor(i/B)
        ans = max(ans, tmp)
        if count > B//2:
            break
else:
    ans = max(0, math.floor(A*N/B) - A*math.floor(N/B))

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
max = 0
i=0
while(1):
 cal = int((A*N)/B) - A*int(N/B)
 if(cal > max):
  max =cal
 i += 1
 if(i > N):
  print(max)
  break;

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = [int(_n) for _n in input().split()]
if A == 1:
    print(0)
elif N >= B-1:
    print(B-1)
else:
    print(N*A//B)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
N = list(map(int, input().split()))
ans = []
for i in range(N[2] + 1):
    f_1 = math.floor((N[0]*(i))/N[1])
    f_2 = N[0] * (math.floor((i)/N[1]))
    ans.append(f_1 + f_2)
ans.sort()
print(ans[-1])

Submission status: Wrong Answer

Solution code:
from math import floor

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

x = None
if N < B:
    x = N
else:
    x = 1
    max_diff = 0
    for _x in range(1, N + 1):
        diff = (x / B) - floor(x / B)
        if max_diff <= diff:
            max_diff = diff
            x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)

Submission status: Wrong Answer

Solution code:
import math


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


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

left = 1
right = N

while right - left > 1:
    mid = (left + right) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))

Submission status: Wrong Answer

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

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(1, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R > maxR:
        maxR = R
        maxX = x
print (maxX)

Submission status: Wrong Answer

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

import math

x = n
tmp1 = math.floor(a*x/b) - a*math.floor(x/b)
ret = tmp1

if n//b == 0:
    print(tmp1)
else:
    q, _ = divmod(n, b)
    for i in range(q,q-3, -1):
        for mod in range(0, b):
            x = i*b-mod
            tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
            ret = max(ret, tmp2)
    print(ret)

Submission status: Wrong Answer

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

print(ans)

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

k = A * N // B
if A * N % B == 0:
    case = [a, b, max(min(B-1,N),1)]
else:
    c = max(1,k*B//A)
    case = [a,b,c,max(min(B-1,N),1)]

ans = -10**9
for i in case:
    ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))

print(ans)

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)


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())
i=0
while(True):
    d=((a*i)//b)-(a*(i//b))
    i=i+1
    if(i>N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break

Submission status: Wrong Answer

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

print((a * x) // b)

Submission status: Wrong Answer

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

maxn = -10
S = min(B,N)
for x in range(S):
    tmp = int(A*x/B)-A*int(x/B)
    if tmp > maxn:
        maxn = tmp
print(maxn)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = (((a*n)//b)*b+a-1)//a
def calc(x):
    return int(a*x/b)-a*int(x/b)
if x+1<=n:
    print(max(calc(x-1), calc(x), calc(x+1)))
else:
    print(max(calc(x), calc(x-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil as c
a,b,n=map(int,input().split())
a,b,n=9,10**12,10**12-1
if b<=n:
  print(a-1)
else:
  print(c(a*n/b-1))

Submission status: Wrong Answer

Solution code:
import math


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

Submission status: Wrong Answer

Solution code:
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1

for x in range(1, n+1):
    score = math.floor(a*x/b) - a* math.floor(x/b)
    if max_score < score:
        max_score = score
        x += 1
    else:
        break

print(max_score)

Submission status: Wrong Answer

Solution code:
import math
li = list(map(int,input().split()))
a = li[0]
b = li[1]
n = li[2]
max_val = 0
for x in range(1, n+1):
    val = math.floor(a*x/b) - math.floor(x/b)
    max_val = max(max_val, val)
print(max_val)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
k = N // B
x = k*B-1
t = int(A*x/B)
u = A*int(x/B)
s = t-u
if s < int(A*N/B)-A*int(N/B):
  s = int(A*N/B)-A*int(N/B)
print(s)