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:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

    C1=main(mid1)
    C2=main(mid2)
    C=max(C,C1,C2)
    if C1>C2:
        ed=mid2
    else:
        st=mid1
if ed-st==2:
    C=max(main(st),main(st+1),main(ed))
print(C)

Submission status: Wrong Answer

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

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

if(N < B):
    print(f(A,B,N))
else:
    print(B-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N+1):
  r = math.floor(A*i/B) - math.floor(i/B)
  res.append(r)
print(max(res))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
temp = min(b,n)
while temp:
    if temp%b:
        print((a*temp)//b)
        break
    temp-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

ABN = list(map(int, input().split()))

#xがBの倍数であれば全体が0
#その一個手前が最大値

if (ABN[2] > ABN[1]):
    print(math.floor(ABN[0] * (ABN[1] - 1) / ABN[1]))
else:
    print(math.floor(ABN[0] * ABN[2] / ABN[1]) - ABN[0] * math.floor(ABN[2] / ABN[1]))

Submission status: Wrong Answer

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

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)

if n <= b:
    print(f(n))
else:
    x = n - (n%b+1)
    print(f(x))

Submission status: Wrong Answer

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

ans = 0
zero_cnt = 0
for i in range(n+1):
    tmp = int(a*i/b) - a*int(i/b)
    if tmp == 0:
        zero_cnt += 1
    if zero_cnt == 10:
        break
    ans = max(ans, int(a*i/b) - a*int(i/b))
print(ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import math

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = 0
for x in ps:
  if N < x: continue
  res = max(res, (A * x) // B - A * (x // B))
  #print((A * x) // B - A * (x // B), x)
print(res)

Submission status: Wrong Answer

Solution code:
[A,B,N] = [int(s) for s in input().rstrip().split(' ')]
if N <= B:
    print(A*N//B)
else:
    print((A*(B-1))//B)

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
x = B
floor = lambda A,B,x: (A*x)//B - A*(x//B)
prev = floor(A,B,x)
while True:
    x -= 1
    c = floor(A,B,x)
    if prev <= c:
        prev = c
    else:
        break
print(prev)

Submission status: Wrong Answer

Solution code:
from math import floor as f
a,b,n=map(int,input().split())
m=0
for x in range(n):
  m=max(m,f(a*x/b)-a*f(x/b))
print(m)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    if a == 1 and b == 1 and n == 1:
        print(1)
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

prev = -1
for n in range(N, 0, -1):
    res = floor(A, B, n)
    if res < prev:
        print(prev)
        break
    prev = res

Submission status: Wrong Answer

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

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

    C1=main(mid1)
    C2=main(mid2)
    C=max(C,C1,C2)
    if C1>C2:
        ed=mid2
    else:
        st=mid1
print(C)

Submission status: Wrong Answer

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

o = x
x = max(0, x - 100000)

m = 0

while x <= o:
    m = max(m, (a*x) // b - a * (x // b))
    x += 1

print(m)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
x=1
max1=0
while x>0 and x<n:
  max1=math.floor((a*x)/b) - a * (math.floor(x/b))
  x+=1
print(max1)

Submission status: Wrong Answer

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

ans = 0
print((a * n // b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    C1=main(mid1)
    C2=main(mid2)
    C=max(C,C1,C2)
    if C1>C2:
        ed=mid2
    else:
        st=mid1
print(C)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
import math
def f(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)
    
min_x=min(N,max(math.floor(N/B)*B-1,0))
min_ax = min(N,(math.floor(A*N/B)*B+A-1)//A)
ans = max(f(A,B,N),f(A,B,min_x),f(A,B,min_ax))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

"""
i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)
"""

print(func(A, B, B-1))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = min(n, a)
tmp = x
while 0 < tmp and b != 1:
    tmp -= 1
    if tmp % b == 0 and 0 < tmp:
        x = tmp
if b == 1:
    print(0)
else:
    print(a * x // b)

Submission status: Wrong Answer

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

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

prev = -1
for n in range(N + 1, 0, -1):
    res = floor(A, B, n)
    if res < prev:
        print(prev)
        break
    prev = res

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
a, b, n = map(int, input().split())
ans1 = a * n // b - a * (n // b)
ans2 = a * (n - 1) // b - a * ((n - 1) // b)
ans3 = a * (n - 2) // b - a * ((n - 2) // b)
print(max(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    print(floor(a*p//b) - a*floor(p//b))
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
ans = 0
for i in range(a):
    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())


c = N // B
d = N % B

if d == 0:
    N -= 1

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
x = B*N//B
floor = lambda A,B,x: (A*x)//B - A*(x//B)
prev = floor(A,B,x)
while True:
    x -= 1
    c = floor(A,B,x)
    if prev <= c:
        prev = c
    else:
        break
print(prev)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    def func(x):
        res = (A * x) // B - A * (x // B)
        return res

    M = 0
    for i in range(N, max(0, N - 10 ** 6), -1):
        tmp = func(i)
        if tmp > M:
            M = tmp

    print(M)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def main(a, b, n):
	ans = 0
	for i in range(max(n + 1 - a - 2, 1), n + 1):
		ans = max(ans, (a * i) // b + a * (i // b))
	return ans


#print(naive(a, b, n))
print(main(a, b, n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = a % b / b
ans = int(a*n/b)-a*int(n/b)
for i in range(n)[::-1]:
    tmp = int(a * i / b) - a * int(i / b)
    ans = max(ans, tmp)
    if tmp < ans:
        break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
import math
def f(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)
    
min_x=min(N,max(math.floor(N/B)*B-1,0))
min_ax = min(N,max(math.floor(A*N/B)*B-1,0))
ans = max(f(A,B,N),f(A,B,min_x),f(A,B,min_ax))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    def func(x):
        res = (A * x) // B - A * (x // B)
        return res

    M = 0
    for i in range(N, max(0, N - 10 ** 5), -1):
        tmp = func(i)
        if tmp > M:
            M = tmp

    print(M)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
def LI():return list(map(int,input().split()))

a,b,n=LI()

def f(x):
    ret=math.floor(a*x/b)-a*math.floor(x/b)
    return ret

if n>=a:
    ans=a-1
else:
    ans=f(n)
print(ans)

Submission status: Wrong Answer

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

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

ans1=calc(a,b,min(b-1,n))
ans2=calc(a,b,n)
print(max(ans1,ans2))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
a, b, n = map(int, input().split())
ans1 = a * n // b - a * (n // b)
ans2 = a * (n - 1) // b - a * ((n - 1) // b)
print(max(ans1, ans2))

Submission status: Wrong Answer

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

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

print(naive(a, b, n))

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
ans = 0
for i in range(1,n):
	tmp = floor((a*i)/b) - a*floor(i/b)
	ans=max(tmp,ans)
print(ans)
# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):

Submission status: Wrong Answer

Solution code:
a, b, n = [int(i) for i in input().split(' ')]
seen = set()
for x in range(1, n + 1):
    value = (a * x) // b - a * (x // b)
    if value in seen:
        print(max(seen))
        break
    seen.add(value)
else:
    print(max(seen))

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
a, b, n = map(int, input().split())
ans = a * n // b - a * (n // b)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = 0
for x in range(1, min(A+1, N+1)):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    m = max(res, m)

print(m)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, min(2 * a, n + 1)):
    ans = max(ans, solve(i))
print(ans)

Submission status: Wrong Answer

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

print(min(N,B-1))

Submission status: Wrong Answer

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

k =0

for i in range (0, 10000000):
	p = math.floor(A*i/B)-A*math.floor(i/B)
	if p> k:
		k = p

print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
mul=0
while mul*b-1<=n:
    mul+=1
mul-=1
x=max(n,mul*b-1)
print((a*x)//b-a*(x//b))

Submission status: Wrong Answer

Solution code:
import math
def floorfunction(A,B,x):
  sTgt=math.floor(A*x/B)-A*math.floor(x/B)
  return sTgt
  
def main():
  A,B,N=map(int,input().split())
  sMax=0
  for i in range(N):
    sTgt=floorfunction(A,B,N)
    if(i==0):
      sMax=sTgt
    else:
      sMax=max(sMax,sTgt)
  print(sMax)
  
if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import random
import copy
import math
def main():
     A,B,N = map(int,input().split())
     ma = 0
     for x in range(1,min(A+1,N+1)):
          ma = max(ma,math.floor(A*x/B)-A*math.floor(x/B))
     print(ma)
                    
main()

Submission status: Wrong Answer

Solution code:
A,B,N=map(int, input().split())
def f(n):
    return A*n//B-A*(n//B)
ans=f(N)
ans=max(ans,f(N//B*B))
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
import math
def f(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)
    
min_x=min(N,max(math.floor(N/B)*B-1,0))
ans = max(f(A,B,N),f(A,B,min_x))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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))