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
from math import sqrt, floor

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


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


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


def main():
    a, b, n = MI()

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for i in range(N):
  Temp = int(A*(i+1)/B) - N * int(A/B)
  if(Temp>ans): ans = Temp

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

else:
    #ans = math.floor(A*N/B) - A*math.floor(N/B)
    ans = (10**100)*(A*N)
    if ans % B == 0:
        ans /= B
        print(int(ans // (10**100)) + 1)
    else:
        ans /= B
        print(int(ans // (10**100)))

Submission status: Wrong Answer

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans = 0
x = 0
t = ((A * x) // B) - (A * (x // B))
while x <= N:
    x += 1
    t2 = ((A * x) // B) - (A * (x // B))
    if t2 <= t and t != 0:
        ans = t
        break
    t = t2

print(ans)

Submission status: Wrong Answer

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - (n%b+1)
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b >= 10 ** 6:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x=[]
x.append(int(a*n/b))
if n>=b:
  x.append(int(a*(b-1)/b))
print(max(x))

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
x3 = B-1
if B-1>N:
    x3 =0
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),f(x3)))

Submission status: Wrong Answer

Solution code:
def hoge(x, A, B):
    return int(A*x / B) - A * int(x / B)
A, B, N = map(int, input().split())
maxval = 0
for i in range(1, N + 1 if N < 10 else 11):
    res = hoge(i, A, B)

    if maxval < res:
        maxval = res

print(res)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=floor(a*n/b)-a*floor(n/b)
x=n//b*b-1
if x<0:
    x=n-1
cand2=floor(a*x/b)-a*floor(x/b)
print(max(cand2,cand1))

Submission status: Wrong Answer

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

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

print(max(f(N - N % B - 1), f(N)))

Submission status: Wrong Answer

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

ans = 0

if b == 1:
  ans = 0

else:
  for x in range(0, a * n, b):
    if x == b:
      ans = 0
    else:
      new = math.floor(x / b) - a * math.floor((x / a) / b)
      if new > ans:
        ans = new

print(int(ans))

Submission status: Wrong Answer

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

if N < B :
  print(N * A // B - A * N // B)
  sys.exit()
else :
  print(((B-1) * A // B) - A * ((B-1) // B))

Submission status: Wrong Answer

Solution code:
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	if(n>b):
		f = math.floor((a*(b-1))/b)
		s = math.floor((b-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	else:
		f = math.floor((a*(n))/b)
		s = math.floor((n)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
s=list(range(1))
import math
for x in range(N):
  s.append(math.floor((A*x)/B)-A*math.floor(x/B))
print(max(s))

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif (n % b - n%(b/a)+1)//(b/a)+1<a:
    x=n-n%b-1
# elif (n%b-n%(b/a)+1)<a:
#     x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math
# m = n % b
#
#
#
# print(math.floor(a*m/b))
#

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

Submission status: Wrong Answer

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

if B > N:
    ans = floor(A*N/B)
    print(ans)
else:
    ans = floor(A*N/B) - A*floor(N/B)
    ans_2nd = 0
    x = (N//B)*B - 1
    temp = floor((A*x)/B) - A*floor(x/B)
    # while ans <= temp and x >= 0:
    #     ans = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # while ans_2nd <= temp and x >= 0:
    #     ans_2nd = temp
    #     temp = floor(A*x/B) - A*floor(x/B)
    #     x -= B
    # prfloor(max(ans, ans_2nd))
    print(max(temp, ans))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
k = N // B
if k == 0:
  x = N
else:
  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)

Submission status: Wrong Answer

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

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

print(min(f(N - N % B - 1), f(N)))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int, input().split()) 
max = -1000
tmp = 0

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

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    a, b, n = map(int, input().split())
    ans = 0
    if b > n:
        ans = (a * (n-1)) // b
    elif b == n:
        ans = (a * (n - 1)) // b
    else:
        ans = (a * b) // b
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    ans = 0

    for i in range(1, min(N+1, 10**6 + 1)):
        ans = max(ans, (A*i)//B - A * (i //B))

    print(ans)

Submission status: Wrong Answer

Solution code:


def solve():
    if n > b:
        print((b-1)*a//b)
    else:
        print((a*n)//b- a*(n//b))
    return


# n = int(input())
a, b, n = [int(s) for s in input().split(" ")]
solve()

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
elif A==B and N>=B:
    print(B-1)
elif A==B and N<B:
    print(N)
  
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

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

ans = 0

if b == 1:
  ans = 0

else:
  for x in range(0, a * n, b):
    if x == b:
      ans = 0
    new = math.floor(x / b) - a * math.floor((x / a) / b)
    if new > ans:
      ans = new

print(int(ans))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=floor(a*n/b)-a*floor(n/b)
x=n-n%b-1
cand2=0
if x>=0:
    cand2=floor(a*x/b)-a*floor(x/b)
cand1=max(cand2,cand1)
print(cand1)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x=[]
x.append(int(a*n/b)-a*int(n/b))
if n>=b:
  t=int(n/b)
  x.append(int(a*(t*b-1)/b)-a*int((t*b-1)/b))
  x.append(int(a*(b-1)/b)-a*int((b-1)/b))
print(max(x))

Submission status: Wrong Answer

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

x = min(b-1, n)
ans = int(a * x / b)
if a == 1 or b == 1 or b == n:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = N//B

print(max(((A*B*k)-A)//B - (k-1)*A , (A*N)//B - A*(N//B)))

Submission status: Wrong Answer

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

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

else:
    #ans = math.floor(A*N/B) - A*math.floor(N/B)
    ans = (10**100)*(A*N)
    ans /= B
    if A == B:
        print(N)
    else:
        print(int(ans // (10**100)))

Submission status: Wrong Answer

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

cnt = 1
buf = []
buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
ans=0
for i in range(N+1):
  ans=max(0,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())
ans = []

if N >= 100000:
    for i in range(N-10000,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Wrong Answer

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

import math
m = n % b

print(math.floor(a*m/b))

Submission status: Wrong Answer

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


resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b-1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def C(x):
    return math.floor(A*x / B) - A*math.floor(x/B)

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

high = N
low = 1
x = N//2
result = 1
count =0
while low < high:

    mae = C(x) - C(x-1)
    ato = C(x+1) -C(x)
    if x == 0:
        mae = 1000
    elif x == N:
        ato == -1000
    if mae > 0 and ato > 0:#単調増加
        low = x +1
        x = (high + low)//2
    elif mae < 0 and ato < 0:#単調減少
        high = x -1
        x = (high + low)//2
    elif mae> 0 and ato < 0:
        result = C(x)
        count = 1
        break
    elif mae == 0 or ato == 0:
        result = C(x)
        count = 1
        break
if count == 1:
    print(max(C(low),C(high),result))
else:
    print(max(C(low),C(high)))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans1 = 0
ans2 = 0
ans = 0
ax = 0
x = 0
c = a*(b-1)
for _ in range(b-1, n+1, b):
    ax += c
    x += b-1
    if ax % b == 0:
        ax = 0
        ans1 += 1
    else:
        ans1 = ax//b
    ans = max(ans, ans1-ans2)
    ans2 += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=floor(a*n/b)-a*floor(n/b)
x=n//b*b-1
cand2=0
if x>=0:
    cand2=floor(a*x/b)-a*floor(x/b)
cand1=max(cand2,cand1)
print(cand1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(min(f(B - 1), f(N)))

Submission status: Wrong Answer

Solution code:
A,B,N=[int(x) for x in input().rstrip().split()]
ans=0
now=0
aa=0

cnt=0

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

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
elif A==B:
  print(B-1)
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

Solution code:
import math
if __name__ == "__main__": 
	string = input()
	l = string.split(" ")
	a = int(l[0])
	b = int(l[1])
	n = int(l[2])
	ans = 0
	if(b < a):
		temp = a
		b = temp
		a = temp
	if(n>b):
		f = math.floor((a*(b-1))/b)
		s = math.floor((b-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	else:
		f = math.floor((a*(n-1))/b)
		s = math.floor((n-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

tans = 0

if B <= N:
  for i in range(B,N+1):
    ans = math.floor(A*i/B) - A*math.floor(i/B)
    #print(i,math.floor(A*i/B), math.floor(i/B))
    tans = max(ans,tans)
else:
  tans = math.floor(A*N/B)
  
#for i in range(1,N+1):
#  ans = math.floor(A*i/B) - A*math.floor(i/B)
#  print(i,math.floor(A*i/B), math.floor(i/B))
#  tans = max(ans,tans)

print(tans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

y = min(b, n)
if y < b:
    print((a*y)//b)
elif y == b:
    print((a*y)//b)
else:
    o = (a*y)//b + a*(y//b)
    p = (a*n)//b + a*(n//b)
    print(max(o, p))

Submission status: Wrong Answer

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

if N <= B :
  print(int(N * A // B) - A * int(N // B))
  sys.exit()
else :
  print(((B-1) * A // B) - A * ((B-1) // B))

Submission status: Wrong Answer

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

if N >= 100000:
    for i in range(N-500,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(A,B,x):
    return (((A*x)//B)-(A*(x//B)))
def main():
    A,B,N=map(int,input().split())
    lb=1
    ub=N
    while(lb<=ub):
        mid=(lb+ub)//2
        if f(A,B,mid)<N:
            lb=mid+1
        elif f(A,B,mid)>N:
            ub=mid-1
        else:
            break
    print(f(A,B,mid))
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math
def main():
    A, B, N = map(int, input().split())
    ans = 0
    x = 0.0001
    while x <= N:
        y = math.floor(A*x/B) - A * math.floor(x/B)
        ans = max(ans, y)
        x += B/A
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

from pprint import pprint
from collections import deque, defaultdict
import sys
import math

sys.setrecursionlimit(10 ** 6)

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


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


def trisect(func):
    left = 0
    right = n
    while abs(right - left) > 0.001:
        d = right - left
        mid_left = left + d / 3
        mid_right = right - d / 3
        if func(mid_left) < func(mid_right):
            left = mid_left
        else:
            right = mid_right
    return left


x = trisect(func)
# print(x)
print(max(func(math.floor(x)), func(math.ceil(x)), func(1), func(n)))

Submission status: Wrong Answer

Solution code:
def main():
    from builtins import int, map, list, print, max
    import sys, math
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
elif A==B:
  print("0")
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

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

if N >= 100000:
    for i in range(N-300,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = -1
c = -1
mx = 0
while True:
  c += 1
  x += b
  if x > n:
    print(mx)
    break
  else:
    mx = max(mx, int(a*x/b)-a*c)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(int(A*N/B)+1):
    tmp_ans = math.floor(i) - A*math.floor(i/A)
    if ans < tmp_ans:
        ans = tmp_ans

print(int(tmp_ans))

Submission status: Wrong Answer

Solution code:
import math
A, B, N = [int(i) for i in input().split()]

max_n = 0
output = 0
memo = set()
for x in range(1,B+1):
    f = math.floor((A*x)/B) - (A* math.floor(x/B))
    if f > max_n:
        max_n = f
        output = x
print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


def solve():
    if n > b:
        print(b-1)
    else:
        print((a*n)//b- a*(n//b))
    return


# n = int(input())
a, b, n = [int(s) for s in input().split(" ")]
solve()

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().strip().split())
if b<n:
    x=n
elif n % b <= n%(b/a):
    x=n-n%b-1
elif (n%b-n%(b/a)+1)<a:
    x=n-n%b-1
else:
    x=n
print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Wrong Answer

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

if N >= 100000:
    for i in range(N-200,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Wrong Answer

Solution code:

# floor(Ax/B)−A×floor(x/B)
a,b,n=map(int,input().split())
x = 0
ans=[]
ans.append(0)
while True:
    Ax = a*x
    A = int((Ax/b))
    B = -a*int(x/b)
    ans.append(A+B)
    if x >= n:
        print(ans[-1])
        break
    if ans[x] > ans[x+1]:
        print(ans[x])
        break
    x+=1

Submission status: Wrong Answer

Solution code:
import math
import random

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(800000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


a, b, n = multi_int_input()

lb = min(b, n)
if b == n:
    lb = n-1
ans1 = ((lb*a)//b)- a*(lb//b)
# ans2 = ((n*a)//b) - a*(n//b)

print(ans1)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if B==1 or A==1:
    ans = 0
elif A==10**6 and B ==10**12:
    ans = 10**6
else:
    while N%B==0:
        N = N-1
    ans = (A*N)//B - A*(N//B)
print(ans)

Submission status: Wrong Answer

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


def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)


ans = function(0)
for i in range((n + 1) // b):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)

Submission status: Wrong Answer

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


num = list(map(int, input().split()))
a = num[0]
b = num[1]
n = num[2]
x = (int(n/b) + 1) * b - 1
max_num = 0
while x % b != 0:
    if x <= n:
        new_num = f(a, b, x)
        if max_num < new_num:
            max_num = new_num
    x -= 1
print(max_num)

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
elif A==B:
  print(N)
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
x = 0
if n<=b:
	x = n
	print(int(a*x/b)-a*int(x/b))
	#print(int((a*((b-1)%b) - (a*(b-1))%b)/b))
else:
	if int(n/b) >=1:
		x = 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:
A, B, N = map(int, input().split())

ans = 0

if N < B:
    ans = int(((A*N)/B))
else:
    n = B//N
    f = 0
    for i in range(n):
        int(A*(N-i)/B)-A*(n-i)
        if f>= ans:
            ans = f

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

        else:
            ans = a-1
            print(ans)

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


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

            print(ans_max)

        else:
            ans_max = 0
            n_tmp = a
            for x in range(n_tmp + 1):
                ans = int(a * x / b) - a * int(x / b)
                #print(ans)
                if ans_max < ans:
                    ans_max = ans

            #print('max##########################')
            print(ans_max)

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

            #print(ans_max)

Submission status: Wrong Answer

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

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

print(hoge)