Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
a, b, n = 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:
    ans = b -1

ans = max(buf)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

_max = 0
for x in range(N, N -10, -1):
    
    num =math.floor(A * x / B) - A * math.floor(x/B) 
    # print(num)
    if  num > _max:
        _max = num

print(_max)

Submission status: Wrong Answer

Solution code:
import numpy as np

ABN=np.array(input().split(" "),dtype=np.int32)
A=ABN[0]
B=ABN[1]
N=ABN[2]

out=1
for x in range(N+1):
    calc=int(A*x//B)-A*int(x//B)
    if(calc>out):
        out=calc

print(out)

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 = 10000
	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 = 12000000
	for x in range(int(N//3),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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pprint import pprint as pp
from pprint import pformat as pf

import math


if __name__ == '__main__':
    a, b, n = map(int, input().split())

    m = 0
    for x in range(n):
        k = ((a * x) // b) - a * (x // b)
        m = max(m, k)
    print(m) # debug

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)
  if int(ABN[0]*ABN[2]/float(ABN[1]))<=ABN[0]-1:
    a=int(ABN[0]*ABN[2]/float(ABN[1]))
    y=a-ABN[0]*int(float(a)/ABN[0])
  else:
    y=ABN[0]-1
  
print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, n = MII()
    maxv = 0
    min_mod = b
    for x in reversed(range(1,n+1)):
        mod = (a*x)%b
        if mod < min_mod:
            min_mod = mod
            v = divf(a*x,b) - a*(divf(x,b))
            maxv = max(maxv, v)
        else:
            break
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B:
    n = N//B
    n = n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
    ans5 = int((A*(n))/B)-A*int((n)/B)
else:
    ans1 = ans
    ans2 = ans
    ans3 = ans
    ans4 = ans
    ans5 = ans


print(max(ans, ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
lst = []
for i in range(N-2,N+1):
    c = int(A*i/B) - A * int(i/B)
    lst.append(c)
print(max(lst))

Submission status: Wrong Answer

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

ans = 0
for i in range(min(A+2, N+1)):
    tmp = ((A*i)//B) - (A*(i//B))
    if tmp >= ans:
        ans = tmp
        
print(ans)

Submission status: Wrong Answer

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

from math import floor

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

Submission status: Wrong Answer

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


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

    low = 0
    high = N

    ans = fs(A, B, low)

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if b < n:
    k = math.floor(n/b)
    ans = max(math.floor(a*(b-1)/b), math.floor(a*n/b),math.floor(a*(k*b-1)/b) )
    print(ans)
else:
    print(math.floor(a*n/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if b <= a:
    if n >= b:
        x = b - 1
        print(math.floor(a * x / b))
    elif n < b:
        x = n
        print(math.floor(a * x / b))
elif b > a:
    if n >= b:
        if n % b != 0:
            x = n
        elif n % b == 0:
            x = n - 1
        print(math.floor(a * x / b) - a * math.floor(x / b))
    elif n < b:
        x = n
        print(math.floor(a * x / b))

Submission status: Wrong Answer

Solution code:
import math

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

max_v = 0
for i in reversed(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)
    # 循環したらとめる
    if N > 100 and i > 2/N:
        break
print(max_v)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
ans = -1
for t in range(N):
    x = N-t
    ansX = A*x//B-A*(x//B)
    if ansX > ans:
        ans = ansX
    elif ansX == ans:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
j=0
for i in range(n,-1):
    if n%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
from sys import stdin
input = stdin.readline
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  sTgt_past=0
  if(N//B>=1):
    print(A-1)
  else:
    sMax=int(A*N/B)-A*int(N/B)
    print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

s = input().split()
n = int(s[2])
list=[math.floor(int(s[0])*i/int(s[1]))-int(s[0])*math.floor(n/int(s[1])) for i in  range(int(n)+1)]
print(max(list))

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
t = N // B
if N % B == 0:
    a = max(0, N-1)
    b = N
    d = max(0,t*B-1)
    e = 1
    f = 0
else:
    a = max(0, t * B - 1)
    b = N
    d = max(0,N-1)
    e = 1
    f = 0

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

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

print(ans)

Submission status: Wrong Answer

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

import math

cnt = 0
box = [0]
floor = math.floor(a*n/b) - a*math.floor(n/b)
box.append(floor)
for x in reversed(range(1, n+1, int(b))):
  floor = math.floor(a*x/b) - a*math.floor(x/b)
  box.append(floor)
  cnt+=1
#  if cnt > b/2+1:
#    break
#  print(x, math.floor(a*x/b), a*math.floor(x/b), floor)

box.sort(reverse=True)
print(box[0])
#print(box)

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
	# for i in range(1,n+1):
	# 	f = math.floor((a*i)/b)
	# 	s = math.floor(i/b)
	# 	temp = int(f) - (a*int(s))
	# 	print(temp,(a*i)/b, a*int(s), i)
	# 	if(temp > ans):
	# 		ans = temp
	if(b>=n):
		f = math.floor((a*(n-1))/b)
		s = math.floor((n-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
		
	else:
		f = math.floor((a*(b-1))/b)
		s = math.floor((b-1)/b)
		temp = int(f) - (a*int(s))
		ans = temp
	print(ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
a, b, n = map(int, input().split())
d = deque(list(math.floor(a*i/b)- a * math.floor(i/b) for i in range((n+1)//2, (n+1)//2+1)))
d.append(math.floor(a*1/b)- a * math.floor(1/b))
d.append(math.floor(a*n/b)- a * math.floor(n/b))
print(max(d))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
print(1000000)

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)

if N > 10000000:
    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))

    print(ans)

else:
    temp = 0
    for i in range(N+1):
        temp = max(temp,f(i))
    print(temp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

from math import floor, ceil, sqrt, factorial, gcd
def main():
    a, b, n = map(int, input().split())
    mx = 0

    if b < n:
        for x in range(b-1, n+1, b):
            yd = (x/b)-floor(x/b)
            if yd > mx:
                mx = yd

            if yd+yd_b < 1:
                yd = (x+1/b)-floor(x+1/b)
                if yd > mx:
                    mx = yd
            yd_b = x
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)

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 = 10000
	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 = 12000000
	for x in range(int(N//1.6),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((((a*(1))//b) - (a *((1)//b)))) == 1:
    g = min(a,b,n)
    if g > 9:
        print(g+(g//10)+1)
    else:
        print(g)
    exit()

if(a > n and b > n):
    print((((a*(n-1))//b) - (a *((n-1)//b))))
    exit()
else:
    if(a > n):
        ans = max((((a*(b-1))//b) - (a *((b-1)//b))),(((a*(n-1))//b) - (a *((n-1)//b))))
    elif(b > n):
        ans = max((((a*(a-1))//b) - (a *((a-1)//b))),(((a*(n-1))//b) - (a *((n-1)//b))))
    else:
        ans = max((((a*(a-1))//b) - (a *((a-1)//b))),(((a*(b-1))//b) - (a *((b-1)//b))))
print(ans)

Submission status: Wrong Answer

Solution code:
a, b , n = map(int, input().split())
def floor_abx(a, b, x):
    return int(a*x/b) - int(x/b)*a 
    
res = 0
for i in range(n+1-a*2, n+1):
    num = floor_abx(a, b, i)
    if res < num:
        res = num
print(res)

Submission status: Wrong Answer

Solution code:
import math
import sys

a, b, n = map(int, input().split())
step = math.ceil(n/(3*(10**6)))
array = range(1, n+1, step)
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans = 0
ans_max = 0
for x in range(1,N+1):
    ans = int(float(A*x)/float(B))-A*int(float(x)/float(B))
    if ans_max < ans:
        ans_max = ans
    if x > B or x > A:
        break
print(ans_max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


a, b, n = map(int, input().split())
li1 = [0, 1, 2, 3, n-3, n-2, n-1, n]
li2 = []
for x in li1:
    an = math.floor(a*x/b) - a * math.floor(x/b)
    li2.append(an)
print(max(li2))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

if b != n:
    print((a*y)//b)
else:
    print((a*y)//b + a*(y//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(m*(B-1)-1+j)
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B)))

Submission status: Wrong Answer

Solution code:
import sys
import math
p = list(map(int, input().split()))
a=p[0]
b=p[1]
n=p[2]
num = - sys.maxsize
for i in range(1,n+1):
    if math.floor(a*i/b) - a*math.floor(i/b) > num and math.floor(a*i/b) - a*math.floor(i/b) <= n:
        num = math.floor(a*i/b) - a*math.floor(i/b)
print(num)

Submission status: Wrong Answer

Solution code:
import numpy as np

ABN=np.array(input().split(" "),dtype=np.int32)
A=ABN[0]
B=ABN[1]
N=ABN[2]

out=0
for x in range(N+1):
    calc=int(A*x//B)-A*int(x//B)
    if(calc>out):
        out=calc

print(out)

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 = 10000
	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 = 12000000
	for x in range(int(N//1.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())
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))
print(max(x))

Submission status: Wrong Answer

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

k = gcd(A, B)

As = A // k
Bs = B // k

# if B < 100:
#     res = []
#     for n in range(min(N+1, B+1)):
#         res.append(round(floor(As*n/Bs)-A*floor(n/B)))
#
#     print(max(res))
#     exit()

if B-1 <= N:
    m, n = B - 1, Bs - 1
elif Bs - 1 <= N:
    m, n = Bs - 1, Bs - 1
else:
    m, n = N, N
print(round(floor(As * n / Bs) - As * floor(m / Bs)))

Submission status: Wrong Answer

Solution code:
import math
import sys
a=input().split()
A=int(a[0])
B=int(a[1])
N=int(a[2])
max=math.floor(A*0/B)-A*math.floor(0/B)
for i in range(N-1,-1,-1):
  if math.floor(A*(i+1)/B)-A*math.floor((i+1)/B)<max:
    print(max)
    sys.exit()
  max=math.floor(A*(i+1)/B)-A*math.floor((i+1)/B)
print(max)

Submission status: Wrong Answer

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

# maxn = -10
# S = min(B,N)
# for x in range(N):
#     tmp = int(A*x/B)-A*int(x/B)
#     if tmp > maxn:
#         maxn = tmp
#     print(x,tmp)
x = min(B, N)
max_num = 0
for i in range(x-100,x+100):
    max_num = max(max_num,int(A*i/B)-A*int(i/B))
print(max_num)