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 math
A,B,N= map(int,input().split())

if B<N:
    lista=(math.floor((A*(B-1))/B)-A*(math.floor((B-1)/B)))
    print(lista)
else:
    list=(math.floor((A*N)/B)-A*(math.floor(N/B)))
    print(list)

Submission status: Wrong Answer

Solution code:
import math

lst = []
A, B, N = map(int,input().split())
for i in range(N + 1):
    res = math.floor((A*i)/B) - A * math.floor(4/B)
    lst.append(res)

print(max(lst))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
S=[0]
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 sys
import math
A, B, N = map(int, input().split())

if A == 1 or B == 1:
  print(0)
  sys.exit()
elif A == B:
  print(N)
  sys.exit()  

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:
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 = n // b

ans = max(buf)
print(ans)

Submission status: Wrong Answer

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

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+1:
  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**6):
    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
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+1):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
print(0)

Submission status: Wrong Answer

Solution code:
import math


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

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

    B_A = 1.0 * B / A

    max_value = -1
    for i in range(1, int(B / B_A) + 2):
        x = B_A * i
        if x > N:
            break
        v = target(x)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_value = v
    print(max_value)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

sys.setrecursionlimit(10 ** 6)

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


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


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


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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int,input().split())
 
l = [N]
if N > B:
 x = math.floor((N+1)/B)
 l.append(x*B-1)

m = [math.floor(A*i/B)-A*math.floor(i/B) for i in l]
print(max(m))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
#1 <= x <= n
#minimize  int(x/b)
#x = int(a*x/b) - a * int(x/b)
k = n%b
#def func(arr):
  #changed_array = int(a*arr/b) - a * int(arr/b)
  #return changed_array 
  
if n < b:
  print(int(a*n/b) - a * int(n/b))
elif n ==b:
  x = n-1
  print(int(a*x/b) - a * int(x/b))
else:
  x = n-k-1
  p = int(a*x/b) - a * int(x/b)
  q = int(a*n/b) - a * int(n/b)
  print(max(p,q))

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=-100
for x in range(1,N+1):
    calc=int(A*x/B)-A*int(x/B)
    if(calc>out):
        out=calc

print(out)

Submission status: Wrong Answer

Solution code:
import numpy as np

num_list = list(map(int, input().split()))
ranges = [0, num_list[2]]

while 1:
    tmp = ranges[0]+(ranges[1]-ranges[0])/2
    if tmp//2 == ranges[0]:
        tmp = np.ceil(tmp)
    medium = np.floor(num_list[0]*tmp/num_list[1])-num_list[0]*np.floor(tmp/num_list[1])
    tmp = tmp+1
    medium_1 = np.floor(num_list[0]*tmp/num_list[1])-num_list[0]*np.floor(tmp/num_list[1])
    tmp = tmp-2
    medium__1 = np.floor(num_list[0]*tmp/num_list[1])-num_list[0]*np.floor(tmp/num_list[1])

    if medium < medium_1:
        ranges = [medium, ranges[1]]
    elif medium < medium__1:
        ranges = [ranges[0], medium]
    else:
        max_num = medium
        break
print(int(max_num))

Submission status: Wrong Answer

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

x=n//b*b
for i in range(n,n//b*b-1,-1):
    cand0=floor(a*i/b)-a*floor(i/b)
    if i<0:
        break
    if cand0>cand1:
        cand1=cand0
print(cand1)

Submission status: Wrong Answer

Solution code:
import math

a, b, n = (int(x) for x in input().split())

ans = 0

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

if a == b :
    ans = math.floor(a * (a - 1) / b) - a * math.floor((a - 1) / b)

if a > b :
    
    for x in range(b - 1, n + 1, b):
        # print(x)
        temp = math.floor(a * x / b) - a * math.floor(x / b)
        # print(temp)
        if ans <= temp :
            ans = temp

print(ans)

Submission status: Wrong Answer

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

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 )+2)-B)
  y_1 = math.ceil(tobi * ((int(N / tobi) //2 )+2))
  y_2 = math.ceil(tobi * ((int(N / tobi) //2 )+2)+B)
  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 )+2,int(N / tobi)):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score

  else:
    for i in range(0 ,(int(N / tobi) //2 )+3, -1):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score
     
  print(p)
 
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
m = 0
if a == 1:
    print(b - 1, n)
else:
    for i in range(1, min(10 ** 6 + 11, n + 1)):
        m = max(m, math.floor((a * i) / b) - a * math.floor(i / b))
        print(i, m)
print(m)

Submission status: Wrong Answer

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

k = (N+1)//B

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

Submission status: Wrong Answer

Solution code:
from math import floor
 
a, b, n = [int(x) for x in input().split()]
result = []
 
for x in range(n-4, n+1):
    value = floor(a*x/b) - a * floor(x/b)
    result.append(value)

print(result)
print(max(result))

Submission status: Wrong Answer

Solution code:
import math

A, B, N = [int(i) for i in input().split()]
ret = math.floor(A*N/B) - A * math.floor(N/B)

for i in range(1,1000) :
  if N - i < 1 :
    break
  if ret < math.floor(A*(N-i)/B) - A * math.floor((N-i)/B) :
    ret = math.floor(A*(N-i)/B) - A * math.floor((N-i)/B)

print(ret)

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 0, -A):
        tmp = (A * i // B) - A * (i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
# Your code here!
import math
 
A,B,N = map(int, input().split())
List=[]
i=1
while i<=N:
    one=math.floor((A*i)/B)
    two=math.floor(i/B)
    three=A*two
    ans=one-three
    List.append(ans)
    if ans==0:
        break
    #print(ans)
    i+=1
#print("ans")
print(max(List))

Submission status: Wrong Answer

Solution code:
a,b,n = (int(x) for x in input().split())
max=0
if n<b:
    max=int(a*n/b)
        
else:
    max=int(a*n/b)-a*int(n/b)
    
print(max)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math as mt

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

    maxn = 0
    
    if N > B:
        nn = N // B
        nnn = nn * B - 1
        maxn = mt.floor(A*nnn/B) - A*mt.floor(nnn/B)
    elif N == B:
        maxn = mt.floor(A*(N-1)/B) - A*mt.floor((N-1)/B)
    else:
        maxn = mt.floor(A*N/B) - A*mt.floor(N/B)
    
    print(maxn)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for x in range(0,N):
  c = decimal.Decimal(str(A*x/B))
  C = int(c.quantize(decimal.Decimal('0'), rounding=decimal.ROUND_FLOOR))
  d = decimal.Decimal(str(x/B))
  D = int(d.quantize(decimal.Decimal('0'), rounding=decimal.ROUND_FLOOR))
  D = D * A
  E = C-D
  S.append(E)
  
print(S.index(max(S)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(x):
  return floor(a*x/b) - a*floor(x/b)


if a*n < b:
  print(f(b-1))
else:  
  ans = 0
  for i in range(1,min(a+1,n+1)):
    ans = max(ans,f(i))

Submission status: Wrong Answer

Solution code:
import math

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

_max = 0
for x in range(N, N -100, -1):
    if x < 1:
        break
    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:
def main() -> None:
    A, B, N = map(int, input().split())
    if N <= A:
        ans = 0
        for i in range(N + 1):
            ans = max(ans, A * i // B - A * (i // B))
        print(ans)
    elif N <= B:
        print(A * N // B)
    else:
        print(A)


if __name__ == '__main__':
    main()

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
            print(math.floor(a * x / b) - a * math.floor(x / b))
        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
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:
            print(fs(A, B, mid))
            return 0
        if tmp > ans:
            ans = tmp
            low = mid + 1
        else:
            high = mid - 1

    #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:
# -*- 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
		#print(maxs)
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 12000000
	for x in range(int(N//7),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:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))
A,B,N =line[0],line[1],line[2]

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

Submission status: Wrong Answer

Solution code:
import math

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

ab = a/b
maxi = 0
st = max(0, n-2*a-1)
for x in range(st, n+1):
    z = 0
    if x < b:
        z = math.floor(ab * x)
    else:
        z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

print(maxi)

Submission status: Wrong Answer

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

ans = set()

if N <= B :
  print(int(N * A / B) - A * int(N / B))
  sys.exit()
else :
  for i in range(B) :
    ans.add(int(i * A / B) - A * int(i / B))
    
print(max(ans))

Submission status: Wrong Answer

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

x = 0
step = int(b/a)
if step == 0 :
    step = 1
while x <= n:
    ans1 = int(a*x/b) - a * int(x/b)
    x += step
    ans2 = int(a*x/b) - a * int(x/b)
    if ans1 > ans2:
        break
print(ans1)

Submission status: Wrong Answer

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

if a % b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n)
else:
    maxT = 0
    i = n
    while i >= n-1000000 and i >= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i -= 1
    print((a*b-a-1)//b)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split(" ")]
ans = 0
idx = 0
for x in range(1, min(A+1,N+1)):
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

for x in range(N, N-A-1, -1):
    if x < 0:
        break
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

print(ans)

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
x = 0
for i in reversed(range(N)):
    if i+1 % B == 0:
        continue
    else:
        x = i+1
        break
print((A*(i+1)//B)-(A*((i+1)//B)))

Submission status: Wrong Answer

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

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 == 1 :
    An = 0
    
if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B == N :
    An = fl(N-1)

print(str(An))

Submission status: Wrong Answer

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

m = n - n % b if n >= b else n

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

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
        v = divf(a*x,b) - a*(divf(x,b))
        maxv = max(maxv, v)
        if mod <= min_mod:
            min_mod = mod
        else:
            break
    print(maxv)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  a, b, n = map(int,input().split())
  if n // b == 0:
    mod = n
  else:
    mod = (n // b) * b - 1
  ans = math.floor(a * mod / b) - a * math.floor(mod / b)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(float,input().split())
 
if N%B == 0:
    tmp = (N//B)*B + (N%B)
    print(int(int(A*(tmp-1)/B) - A*int((tmp-1)/B)))
else:
    tmp = (N//B)*B + (N%B)
    if N%B == 1:
        print(int(int(A*(tmp-2)/B) - A*int((tmp-2)/B)))
    else:
        print(int(int(A*(tmp)/B) - A*int((tmp)/B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x=b-1
i=0
if a==1:
  print('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:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    #xans=(N//B)*B+(B-1)
    #print(xans,N-(N%B)-1+B)
    xans=N-(N%B)-1+B
    #関数floor(x/B)は周期Bの関数でx%B=-1のとき
    #同じfloor(x/B)のなかでfloor(A*x/B)が最大化できる？
    if xans>N:xans=N
    print(f(A,B,xans))
    
#%%submit!
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from decimal import *


def target(x):
    x = Decimal(x)
    return ((A * x) / B).to_integral_exact(rounding=ROUND_FLOOR) - A * ((x / B)).to_integral_exact(rounding=ROUND_FLOOR)


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

left = 1
right = N

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


print(target(right))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
def f(x):
    return int(a*x/b) - a*int(x/b)
syou = n//b
Max = 0
for i in range(0,a):
    syou1 = syou - i
    Max = max(f(syou1-1),f(syou-1),Max)
Max = max(Max,f(n))
print(Max)

Submission status: Wrong Answer

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

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

sys.setrecursionlimit(10 ** 6)

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


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


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


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

Submission status: Wrong Answer

Solution code:
import math
a,b,n=(input().split())
A=int(a)
B=int(b)
N=int(n)
x=0
c=0
while x<=N:
    if (math.floor(A*x/B)-A*math.floor(x/B))<(math.floor(A*(x+1)/B)-A*math.floor((x+1)/B)):
        c=math.floor(A*(x+1)/B)-A*math.floor((x+1)/B)
        x=x+1
print(c)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

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


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

if A == B:
    x = A - 1
    print(f(x))

else:
    res = 0
    left = 0
    right = N

    left_res = 0
    right_res = 0

    while (left+1) != right:
        left_res = f(left)
        right_res = f(right)
        mid = (right+left)//2
        if left_res > right_res:
            right = mid
        else:
            left = mid

    print(max(f(left),f(right)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# A, B, N = map(int, input().split())
A, B, N = 5, 7, 4

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


def calculate(a, b, n):
    s1 =  a * n // b
    if n == b:
        s1 = a*(n-1) // b
    if N > b:
        if n >= 2 * b:
            x = b + b - 1
        else:
            x = n
        return max(s1,(a * x) // b + a * (x // b))

    return s1


print(calculate(A, B, N))

Submission status: Wrong Answer

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

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(1,N+1):
    calc=int(A*x//B)-A*int(x//B)
    if(calc>out):
        out=calc

print(out)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
def equation(i,j,k):
    return math.floor((i*K)/j)-i*math.floor(k/j)
if N<B:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    K = B//N
    alpha = equation(A,B,N*K-1)
    bata = equation(A,B,min(N,N*(K+1)))
    ganma = equation(A,B,N*K)
    print(max(alpha,bata,ganma))

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
    yd_b = 1

    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 = yd
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys

a, b, n = map(int, input().split())
step = math.ceil(n/(3*(10**6)+1000))
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:
import math
import random

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

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

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

print(max)

Submission status: Wrong Answer

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

if N%B !=0:
  x_1 = (N//B)*B-1
  if x_1 == -1:
    x_1 = N
  x_2 = N
else:
  x_1 = N-1
  x_2 = N-1
ans_1 = math.floor(A*x_1/B)-A*math.floor(x_1/B)
ans_2 = math.floor(A*x_2/B)-A*math.floor(x_2/B)
if ans_1 >= ans_2:
  print(ans_1)
else:
  print(ans_2)

Submission status: Wrong Answer

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

in_a = list(map(int, input().split()))
A = in_a[0]
B = in_a[1]
N = in_a[2]

ans = 0

if ( B>N ):
  X = N
  ans = math.floor(A*X/B) - ( A * math.floor(X/B) )
  
else:
  M = math.floor( (N/B)+1 )
  for i in range(M-1,M):
    X = ( i * B ) - 1
    temp = math.floor(A*X/B) - ( A * math.floor(X/B) )
    if ( temp>ans ):
      ans = temp

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal
a,b,n = map(int,input().split())
ans = 0
al = []
    
for i in range(n,-1,-1):
    t = Decimal(str(a))*Decimal(str(i))//Decimal(str(b))
    t2 = Decimal(str(a))*(Decimal(str(i))//Decimal(str(b)))
    ans = t-t2
    al.append(ans)
    if len(al) > 100000:
        if al[-1] <= al[-100001]:
            break
            
if max(al) < 0:
    print(0)
else:
    print(max(al))