Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    ans = int(a*n/b) - a*int(n/b)
    for i in range(1,min(n//b+1,b*b+1)):
        if i*b<=n:
            x = int(a*(b*i-1)/b) - a*int((b*i-1)/b)
            ans = max(ans,x)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
li=list(map(int,input().split()))
a=li[0]
b=li[1]
n=li[2]
c=int((a*n)/b)
d=int(n/b)


if c>0:
  e=int(c-a*d)
  print(e)
else:
  pass

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 = int(B_A * i)+1
        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:
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 ** 8 + 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())
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
cnt=0
for i in range(n,n//b*b-1,-1):
    cnt+=1
    cand0=floor(a*i/b)-a*floor(i/b)
    if i<0:
        break
    if cand0>cand1:
        cand1=cand0
    if cnt>10**8:
        break
print(cand1)

Submission status: Wrong Answer

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

def binary_search():
    low = 1
    high = n

    m = -99999999999999

    while low <= high:
        mid = (low + high) // 2

        l = int(a*low/b) - a * (int(low/b))
        h = int(a*high/b) - a * (int(high/b))

        m = max(m, h, l)

        if h > l:
            high = mid - 1
        else:
            low = mid + 1

    return m


print(binary_search())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

_max = 0
for x in range(N, N -10000, -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:
import math
import sys
#a,b,n
a,b,n = (int(x) for x in input().split())

wk_n = n
wk_xxx = 0
wk_x = 0
cnt=0

while wk_n >= 1 and cnt <= 1000000:
#    print(a,b,n,wk_n,wk_x,wk_n/b - math.floor(wk_n/b))
    if wk_n/b - math.floor(wk_n/b)  >= wk_xxx :
        wk_xxx = wk_n/b - math.floor(wk_n/b)
        wk_x = wk_n
    wk_n-=1
    cnt+=1

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

Submission status: Wrong Answer

Solution code:
import math

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

m = b/a
if b <= n:
    print(math.floor(a*(b-m)/b) - a*math.floor((b-m)/b))
else:
    print(math.floor(a*n/b) - a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  ans = math.floor(A*N/B) - A*math.floor(N/B)
else:
  if N%B >= a:
    ans = math.floor(A*a/B) - A*math.floor(a/B)
  else:
    ans = math.floor(A*N/B) - A*math.floor(N/B)
print(ans)

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 = n - 4
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 5
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 6
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 7
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 8
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 9
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 10
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))
n = min(n, 4)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 5)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 6)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 7)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 8)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 9)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(n, 10)
ans = max(ans, int((a * n) / b) - a * int(n / b))
print(ans)

Submission status: Wrong Answer

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

from sys import stdin
import numpy as np


def main():
    a, b, n = map(int, stdin.readline().split())
    # a, b, n = 100, 37, 300

    for j in range(0, -b + 1, -1):
        for i in range(0, n // b + 1):
            x = (b - 1) + (b * i) + j
            if 0 <= x <= n:
                print(int(np.floor(a * x / b) - a * np.floor(x / b)))
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt, floor

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


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


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


def main():
    a, b, n = MI()
    # max = 0
    # for x in range(1, n + 1):
    #     r = floor((a * x) / b) - a * floor(x / b)
    #     if max < r:
    #         max = r

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
maxi = min(A,N)
ans = 0
for i in range(1,maxi+1):
    ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
if A<N:
    for i in range(max(A,B-A),B+1):
        ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

import math
c=math.gcd(a,b)

if n<b:
  x=n
else:
  x=n%b
  if x==0:
    if n>=c:
      x=c-1
    else:
      x=b-1
print(int(a*x/b)-a*int(x/b))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    c = math.floor(a*(b-1)/b)-a*math.floor((b-1)/b)
print(m)

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

k = (N+1)//B

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

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(12000000,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 = list(map(int, input().split()))
x, ans = 1, 0
while True:
  if ans < int(a * x / b) - a * int(x / b):
    ans = int(a * x / b) - a * int(x / b)
  else:
    print(x)
    break
    x += 1

Submission status: Wrong Answer

Solution code:
import math

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

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

print(maxnum)

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**3):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans
print(ans)

Submission status: Wrong Answer

Solution code:
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),A-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())
ans = 0
print(int(abs(((n//b * b -1)/b - ((n//b * b -1)// b)) * a)))
"""for x in range(1,n+1):
    f = x / b - int(x / b) 
    if ans <= f:
        ans = f
print(int(ans * a))"""

Submission status: Wrong Answer

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

n = b if n > b else n
ans = 0
for x in range(n, 0, -1):
    if x > b:
        continue
    ans = max(a * x // b - a * (x // b), ans)
    break

print(ans)

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
  if(N//B>=1):
    print(int(A*(N-1)/B)-A*int((N-1)/B))
  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
a,b,n = map(int,input().split())
x = n
kk = []
for i in range(b):
  kk.append(math.floor(a*x/b)-a*math.floor(x/b))
  x -= 1
print(max(kk))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from pprint import pprint

A, B, N = map(int, sys.stdin.readline().strip().split())

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


right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    if func(mid_left) <= func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)

ans = -1 * float("inf")
for i in range(left, right+1):
    print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys

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

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())
ans = -1
for t in range(N):
    x = t
    ansX = A*x//B-A*(x//B)
    if ansX > ans:
        ans = ansX
    elif ansX == ans:
        break
if A*N//B-A*(N//B) > ans:
    ans = A*N//B-A*(N//B)
    
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
lst = []
for i in range(N,N+2):
    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())
ans = 0
p = 0
for i in reversed(range(1, n+1)):
    t = math.floor(a*i/b) - a * math.floor(i/b)
    if ans < t:
        ans = t
    if p >= t:
        break
    else:
        p = t

print(ans)

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:
a, b, n = map(int, input().split())
x = 0
m = 0
for x in range(b-100, b):
  value = a*x//b - a*(x//b)
  if value > m:
    m = value
print(m)

Submission status: Wrong Answer

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

def obj_f(x):
    res = int(a*x/b) - a*int(x/b)
    return(res)

x = n/2
prev_x = 0
next_x = n

while True:
    if obj_f(((x + next_x)/2)) >= obj_f(((x + prev_x)/2)):
        prev_x = x
        x = ((x + next_x)/2)
    else:
        next_x = x
        x = ((x + prev_x)/2)
    if x - prev_x < 1 and next_x - x < 1:
        break

import math

kouho = math.floor(x)
print(max([obj_f(kouho - 1), obj_f(kouho), obj_f(kouho + 1)]))

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
maxi = min(A,N)
ans = 0
for i in range(1,maxi+1):
    ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
if A<N:
    for i in range(max(A,B-A),B):
        ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
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-1, (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:
import math
ans=-100000000
a,b,n=map(int,input().split())
st=0
if n>=10000000:
    st=n-10000000
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b-0.00001)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
from bisect import bisect_left

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

def solve(A: int, B: int, N: int):
    def func(x):
        return math.floor(A/B * (x%B))

    leftmost = 1
    rightmost = min(N,B)
    midpoint = rightmost // 2

    # for _ in range(10**5):
    #     y = func(rightmost)
    #     if y < N:
    #         leftmost = midpoint
    #     elif y > N:
    #         rightmost = midpoint
    #     else:
    #         break

    #     midpoint = (leftmost+rightmost) // 2
    
    midpoint = rightmost
    ans = math.floor(A*midpoint/B) - A*math.floor(midpoint/B)
    print(ans)

    # i = 0
    # over_N =0
    # while over_N < N:
    #     x = 10 * 10**i
    #     over_N = func(A, B, x)
    #     i += 1

    # while True:
    #     out = func(A, B, x)
    #     if  out <= N:
    #         break
    #     else:
    #         x -= 1

    # print(func(A, B, x))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

z = 0

if n < b:
    count = 0
    g = n * a
    while g > b:
        g = g - b
        count += 1
    z = count
else:
    z = a - 1

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

Submission status: Wrong Answer

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

            #print(i)
            #print(tmp)
            if max_int < tmp:
                max_int = tmp

print(max_int)

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 i > 100000000000:
        break
print(max_v)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
lists = []
for x in range(0, N+1):
    i = math.floor(A * x / B)
    j = A * (math.floor(x / B))
    result = i - j
    lists.append(result)
print(lists[-1])

Submission status: Wrong Answer

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

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*b-1),f(syou*b-1),Max)
Max = max(Max,f(n))
print(Max)

Submission status: Wrong Answer

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

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

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

print(max(ans, function(n)))

Submission status: Wrong Answer

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

# ans = 0
# for x in range(N+1):
#   A_x = A * x
#   left_ = int(A_x / B)
#   right_ = A * int(x / B)
#   # if fnc_ <= N:
#   #   ans = max(ans, fnc_)

#   print("x", x)
#   print("left_", left_)
#   print("right_", right_)
#   print("fnc_", left_ - right_)


# print(ans)


if B > N:
  print(int(A * N / B))
elif B >= N:
  left_ = int(A * N / B)
  right_ = (N // B) * A
  print(left_ - right_)

Submission status: Wrong Answer

Solution code:
from decimal import *


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


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:
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(max(result))

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//1.5),N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



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

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

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

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


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

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

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

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

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import math

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

_max = 0
for x in range(N, N -1000, -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)