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 io import StringIO
import unittest
import math

def resolve():
    a, b, n = map(int, input().split())
    # a = 10 ** 6
    # b = 10 ** 12
    # n = 10 ** 12

    # for i in range(n, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    # if n // b * b - 1 >= 0:
    if b < n:
        n = n // b * b - 1


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


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

    # print('ans')
    # print(n, ans)
    print(ans)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

max(list(map(lambda y: keisan(a, b, y) ,range(1,n+1))))

Submission status: Wrong Answer

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

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, min(1000000, n)):
  n = n - 1
  ans=max(ans, int((a * i) / b) - a * int(i / b))
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, n = [int(x) for x in input().split()]
l = []
for i in range(1, n+1):
    c = (a*i)//b - a*(i//b)
    d = a*(i+1)//b - a*((i+1)//b)
    if c - d >= 0:
        print(c)
        break

Submission status: Wrong Answer

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

lo = 1
hi = N

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

ans = 0
if B-1<=N:
    ans = f(B-1)

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

ans = max(ans,f(lo),f(N-1),f(B*N//B-1),f(B-1))+1

print(ans)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

x = 0
y = 0
z = 0

if n < b:
    z = int((a * n) / b) - a * int(n / b)
else:
    z = a - 1

print("{}".format(z))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 6000000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 6000000
	for x in range(A,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def resolve():
    a, b, n = map(int, input().split())
    # a = 10 ** 6
    # b = 10 ** 12
    # n = 10 ** 12

    # for i in range(n, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    # if n // b * b - 1 >= 0:
    if b < n:
        n = n // b * b - 1


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


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

    # print('ans')
    # print(n, ans)
    print(ans)

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

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

Submission status: Wrong Answer

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

print(max_int)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
if b>n:
    print(math.floor(a*n/b))
elif min([a,b,n]) == n:
    print(math.floor(a*n/b)-a*math.floor(n/b))
else:
    x = a-1 if a>b else b-1
    print(math.floor(a*x/b)-a*math.floor(x/b))

Submission status: Wrong Answer

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

ra = []
for i in reversed(range(1, N+1)):
  temp = math.floor(A * i / B) - (A * math.floor(i / B))
  if not temp in ra:
    ra.append(temp)
  else:
    if temp > 0:
      break
  
print(max(ra))

Submission status: Wrong Answer

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

max_of_x = min(B, N)
max = int(A*max_of_x/B)

for x in range(max_of_x, N+1):
    score = int(A*x/B) + A*int(x/B)
    if score>max:
        max = score

print(max)

Submission status: Wrong Answer

Solution code:
import math
A ,B ,N = map(int,input().split())
l = 0
t = A/B
for x in range(1,10):
    if math.floor(t * x)-A*math.floor(x/B) > l:
        l=math.floor(t * x)-A*math.floor(x/B)
print(l)

Submission status: Wrong Answer

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

aaa = math.floor(A * N / B) - A * math.floor(N / B)

v = N % B
v += 1
bbb = 0
if N - v >= 1:
    bbb = math.floor(A * (N - v) / B) - A * math.floor((N - v)/ B)
ccc = 0
if B - 1 >= 1:
    ccc = math.floor(A * min((B - 1), N) / B)

print(max(aaa, bbb, ccc))

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, min(100, n)):
  n = n - 1
  ans=max(ans, int((a * i) / b) - a * int(i / b))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor
A, B , N = map(int, input().split())
List = []
for x in range(N-1,N+2):
    Answer = abs(floor((A*x)/B) - (A*floor(x/B)))
    List.append(Answer)
# print(List)
print(max(List))

Submission status: Wrong Answer

Solution code:
def main():
  import math
  A, B, N = map(int, input().split())
  p = 0
  tobi = B / A
  
  y_0 = math.ceil(tobi * ((int(N / tobi) //2 )+1))
  y_1 = math.ceil(tobi * ((int(N / tobi) //2 )+2))
  y_2 = math.ceil(tobi * ((int(N / tobi) //2 )+3))
  start_0 = ((A * y_0) // B) -  (A *(y_0 // B))
  start_1 = ((A * y_1) // B) -  (A *(y_1 // B))
  start_2 = ((A * y_2) // B) -  (A *(y_1 // B))
  
  if start_2 > start_1: 
    for i in range(int(N / tobi) //2 ,int(N / tobi)):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score
      elif score < p:
        break
  else:
    for i in range(0 ,int(N / tobi) //2, -1):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score
      elif score < p:
        break      
  print(p)

main()

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) - math.floor(n / b)
print(tmp)

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
res = 0
if a < n:
	if b >= a:
		if b >= n:
			t = math.ceil(b / a)
			res = n // t
			print(res)
		else:
			res = a - 1
			print(res)
	else:
		res = b - 1
		print(res)
else:
	if b >= a:
		t = math.ceil(b / a)
		res = n // t
		print(res)
	else:
		res = n
		print(res)

Submission status: Wrong Answer

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

for i in range(b+1):
  w=int(a*i/b)-a*int(i/b)
  if m<w or m==-1:
    m=w
print(m)
"""

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

Submission status: Wrong Answer

Solution code:
ABN = [int(x) for x in input().split()]


y=0
n=[]
if ABN[2]<ABN[1]-1:
  y=int(ABN[0]*ABN[2]/float(ABN[1]))-ABN[0]*int(float(ABN[2])/ABN[1])
else:
  y=ABN[0]-int(float(ABN[0])/float(ABN[1])+1)
  for a in range(1,int(ABN[0]*ABN[2]/float(ABN[1]))+1):
    if y<a-ABN[0]*int(a/float(ABN[0])):
      y=a-ABN[0]*int(a/float(ABN[0]))
  
print(y)

Submission status: Wrong Answer

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An =fl(N)
    
if B <=N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break

print(str(An))

Submission status: Wrong Answer

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

k = (N+1)//B

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
def f(x):
    return int(a*x/b) - a*int(x/b)
syou = n//b
if syou >= 1:
    Max = max(f(syou*b-1),f(n))
else:
    Max = f(n)
print(Max)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(10**5):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N <= 5000000:
    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, 600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

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

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

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

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

Submission status: Wrong Answer

Solution code:
import math

#X=int(input())
# a=int(input())
A,B,N=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

s=N//B

if s==0:
  x=N
else:
  x=s*B-1

#print(x)

#ans = math.floor(A*x/B) - A * math.floor(x/B)
ans = int(x/B*A) - A * int(x/B)
#ans1 = math.floor(A/B*N) - A * math.floor(N/B)

#if ans1 > ans:
#  ans = ans1

#print(a,b)
print(ans)

Submission status: Wrong Answer

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


def calc(x):
    return (A*x)//B - A*(x//B)

index = 1
prev = -1
max_num = 0
flag = True
if B == 1:
    flag = False
    max_num = 0

if A >= B:
    flag = False
    max_num = calc(N)

while flag and index <= N:
    tmp = calc(index)
    if tmp < prev:
        flag = False
    else:
        prev = tmp
    if max_num < tmp:
        max_num = tmp
    index += 1

print(max_num)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y
ans = []
if b > n:
    print(func(n))
else:
    c = (n//b) -1
    d = b-1
    print(func(b*c + d))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
ans = -1145141919810931931
Flag = True
for x in range(1, N+1, max(1, int(B/A))):
    a = int(A*x/B) - A*int(x/B)
    if a>ans:
        ans = a
        Flag = True
    elif Flag:
        Flag = False
    else:
        break

a = int(A*N/B) - A*int(N/B)
if a>ans:
    ans = a
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

max_v = 0
if A > B:
    for i in range(1, N + 1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        print(current_max_v, end="")
        if i != 1 and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
if B >= A:
    for i in range(N, 0, -1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        print(current_max_v, end="")
        if i != N and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
print(max_v)

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))
print((A*(B-1)) // B  - A * ((B-1) // B ))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
a,b,n = MI()
i = a*n//b
def solve(x):
  return math.floor(a*x/b) - a* math.floor(x/b)
ans = max(solve(i),solve(i+1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int,input().split())
first = [A % B, 1 % B]
kekka = 1
sa = 1 % B - A % B

for i in range(N):
    sa_ = (i+1) % B - (A * (i+1)) % B
    if sa_ >= sa:
        sa = sa_
        kekka = (i+1)
    if i != 0 and first[0] == (A * (i+1)) % B and first[1] == (i+1) % B:
        break

res = math.floor((A * kekka) / B) - A * math.floor(kekka / B)

print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 6000000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 6000000
	for x in range(N//2,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

if B>N:
  print(A*N//B)
  exit()
list=0
for i in range((9*N//10),N+1):
  if i>B:
    list=A*i//B
  else:
    c=((A*i)//B)-(A*(i//B-1))
    if list<c:
      list=c
print(list)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        ans3=int(a*(b-1)/b)-a*int((b-1)/b)
        ans4=int(a*(b+1)/b)-a*int((b+1)/b)
        ans5=int(a*(2*b-1)/b)-a*int((2*b-1)/b)
        ans6=int(a*(2*b+1)/b)-a*int((2*b+1)/b)
        p=n//b
        ans7=ans5=int(a*(p*b-1)/b)-a*int((p*b-1)/b)
        print(max(ans,ans2,ans3,ans4,ans5,ans6,ans7))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print(max(ans,ans2,now))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print(max(ans,0))

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A,B,N = [int(item) for item in input().split()]

    def func(x):
        first = int(A * x / B)
        second = A * int(x/B)
        return first - second

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

A, B , N=  [int(i) for i in input().split()]

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

#else:

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    a,b,n=map(int,input().split())
    def main(x):
        return (a*x)//b-a*(x//b)

    if n%b==0:
        print(main(n-1))
    else:
        print(main(n))

resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import floor
def main():
    A, B, N = map(int, input().split())
    x = max(B - 1, N)
    print(floor(A*x/B) - A*floor(x/B))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

ans = f(a,b,n)
if (n < b/a):
	ans = f(a,b,0)
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
max = 0
x = 0
n = int(B/A)
if(n < 1):n=1

while(x <= N):
  f = int(A*x/B) - A*int(x/B)
  x += n
  #x += 1
  #print(f)
  if(max <= f):
    max = f
  if(max != 0 and f == 0):
    break
print(max)

Submission status: Wrong Answer

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


def solve(A: int, B: int, N: int):
    if A == 1: return 0

    if N < B:
        x = N
    else:
        md = N % B
        x = N - (md + 1)
    # print(md, x)
    return int((A*x)/B) - A * int(x/B)

    # m = -1
    # for i in range(N+1):
    #     x = i
    #     m = max([m, int((A*x)/B) - A * int(x/B)])
    # return m


# 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
    # N = pow(10, 9)
    print(solve(A, B, N))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
num = input()
num = num.split(' ')

A = int(num[0])
B = int(num[1])
N = int(num[2])

import math
import sys

max = sys.float_info.min
for x in range(N + 1):
  ans = math.floor(A*x/B) - A * math.floor(x/B)

  if ans > max:
    max = ans

print(max)

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 - 1
  ans=max(ans, int((a * i) / b) - a * int(i / b))
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a


def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


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

if a != b:
    a,b = reduce(a,b)

# print(a,b)

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


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

#print(a,b,x)
print(ans)

Submission status: Wrong Answer

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

print(max)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(10**3):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

cal = math.floor(A*(N-1)/10) - A * math.floor((N-1)/B)
print(cal + 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
print(2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)