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:
def target(x):
    return (A * x) // B - A * (x // B)


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

left = -1
right = N

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

if right + 1 <= N and target(right + 1) > target(right):
    print(target(right + 1))
elif right - 1 >= 1 and target(right - 1) > target(right):
    print(target(right - 1))
else:
    print(target(right))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
for x in range(N-1,N):
    print(max([math.floor(A*x/B) , A*math.floor(x/B)]))

Submission status: Wrong Answer

Solution code:

a,b,n=map(int,input().split())
a1=int((a*n)/b)-a*int(n/b)
i=int((n+1)/b)
if i!=0:
    a2=int((a*(i*b-1))/b)-a*int((i*b-1)/b)
    a3=int((a*(b-1))/b)-a*int((b-1)/b)
    print(max(a1,a2,a3))
else:
    print(a1)

Submission status: Wrong Answer

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

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

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

print(0)

Submission status: Wrong Answer

Solution code:
def cal(A,B,x):
    return int((A*x)/B) - A*int(x/B)

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        d = N // B
        ans = cal(A,B,B*d-1)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x = N
for x in reversed(range(1,N+1)):
  if x % B != 0:
    print(int(A*x/B)-A*int(x/B))
    exit()

    
print(0)

Submission status: Wrong Answer

Solution code:
#n=int(input())
a,b,n=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import math
if n <b:
    x=n
    v=a*x
    v=v//b
    #ans=math.floor((x/b)*a)
    ans=v
else:
    ans=0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

max_k = calc(a,b,n)

if ((b-1 >= 1) and (b-1 <=n)):
    k = calc(a,b,b-1)
    if max_k < k:
            max_k = k

print(max_k)

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect

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

def solve(a, b, n):
    left = 1
    right = n
    while right - left >= 3:
        m1 = left + (right - left) // 3
        m2 = left + (right - left) // 3 * 2
        val1 = query_value(a, b, m1)
        val2 = query_value(a, b, m2)
        if val1 >= val2:
            right = m2
        else:
            left = m1
    max_val = - 10 ** 60
    for i in range(left, right + 1):
        val = query_value(a, b, i)
        max_val = max(max_val, val)
    return max_val

def main():
    a, b, n = map(int, input().split())
    print(solve(a, b, n))

if __name__ == "__main__":
    main()

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 >= 8: 
    for i in range(0,1000000):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**6-10**5-10**4-10**3-10**2,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))

Submission status: Wrong Answer

Solution code:
# D - Floor Function

from math import floor

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

if B < N:
    mx = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
else:
    mx = floor(A * N / B) - A * floor(N / B)

# mx = -1 * float('inf')
# i = 0

# for i in range(N + 1):
#     result = floor(A * i / B) - A * floor(i / B)
#     print(i, result)
#     if mx <= result:
#         mx = result

print(mx)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

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

if b<=x:
    print(f(b))
else:
    print(f(x))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
if x2 <= 0:
    x2 =1
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)

print(max(f(x1), f(x2)))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(i) for i in input().split())
if N > B:
  print(A-1)
else:
  print(math.floor(A*N/B) - A*math.floor(N/B))

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,n=LI()

  # right=n
  # ans=math.floor(a*right/b)-a*math.floor(right/b)
  # left=0
  # while left<=right:
  #   half=(left+right)//2
  #   _ans=math.floor(a*half/b)-a*math.floor(half/b)
  #   if _ans==ans:
  #     return ans
  #   elif _ans>ans:
  #     right=half-1
  #     ans=_ans
  #   else:
  #     left=half+1

  ans=int(a*1/b)-a*int(1/b)
  x=int(math.sqrt(n))
  for i in range(n-x,n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    a, b, n = map(int, input().split())
    # a, b, n = 10 ** 6, 1, 10 ** 12
    max = 0
    if a * n >= b:
        if n < b:
            max = math.floor(a * n / b)
        else:
            max = math.floor(a*n/b)-a*(math.floor(n/b))
    print(max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for x in range(b, 0, -1):
    ans = a*x // b
    break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC165c
last = 0


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)
    from math import floor
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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

    def evaluate(number):
        return floor(a*number/b)-a*floor(number/b)
        if number < 100:  # もっと高い値を探せ
            return 1
        if number == 100:  # まさにこの値
            return 0
        if number > 100:  # もっと低い値を探せ
            return - 1

    def binary_search(low, high):
        global last
        lowest = low
        highest = high
        while low < high:  # high-low >= 10**-12 ←これ以下の誤差を許容
            mid = (low + high) // 2
            left = (low + mid) // 2
            right = (mid+high)//2
            lv = evaluate(left)
            rv = evaluate(right)
            mv = evaluate(mid)
            #print(low, high)
            if lv < rv:
                last = max(mv, rv)
                low = mid
                lowest = mid
            else:
                last = max(mv, lv)
                high = mid
                highest = mid
            continue

            if guess == 0:
                return [mid, mid]
            if guess < 0:
                high = mid - 1  # 連続値の場合mid
                highest = mid
            else:
                low = mid + 1  # 連続値の場合mid
                lowest = mid

        return [lowest, highest]

    t = binary_search(0, n + 1)[0]
    #print(t, last)
    print(max(evaluate(t-2), evaluate(t-1), evaluate(t),
              evaluate(t+1), evaluate(t+2), last))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
a1=int((a*n)/b)-a*int(n/b)
i=int((n+1)/b)
if i!=0:
    a2=int((a*(i*b-1))/b)-a*int((i*b-1)/b)
    a3=int((a*b-1)/b)-a*int((b-1)/b)
    print(max(a1,a2,a3))
else:
    print(a1)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    import math
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    A, B, N = [int(x) for x in input().strip().split()]
    ans = 0
    for x in range(N, N-A-1, -1):
        ans = max(ans, math.floor((A*x)/B)-A*math.floor(x/B), 0)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
#(a*x)//b - a*(x//b) の最大値を求める
ax_list = [a*i for i in range(1,n+1)]
if b > n:
    # ax//b だけ考えればいい
    print(ax_list[-1]//b)
else:
    # ax//b か　bより大きいx で探す
    maximum = 0
    for i in range(b, n+1):
        temp = a*i//b - a*(i//b)
        if temp > maximum:
            maximum = temp
    print(maximum)

Submission status: Wrong Answer

Solution code:
def floor(t):
    return int(t)


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


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

    ans = 0

    low = 0
    high = N

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

    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 n<=b:
    ans = math.floor(a*n/b)
else:
    for i in range(n,1,-1):
        if a*math.floor(i/b)<math.floor(a*i/b):
            ans=math.floor(a*i/b)-a*math.floor(i/b)
            break

print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    # import random

    a, b, n = map(int, input().split())
    """
    a = random.randint(1, 10**6)
    b  = random.randint(1, 10**6)
    n = random.randint(1, 10**12)
    """
    # print(a, b, n)
    if b > n:
        # print('a')
        print(int(math.floor(a*n/b) - a*math.floor(n/b)))
        exit()

    if n/b <= 2*10**6:
        ans = int(math.floor(a*n/b)-a*math.floor(n/b))
        for i in range(b-1, n+1, b):
            temp =  math.floor(a*i/b)-a*math.floor(i/b)
            if ans < temp:
                ans = temp
        # print('b')
        print(int(ans))
        exit()

    ans = int(math.floor(a*n/b)-a*math.floor(n/b))
    i = b-1
    # ans_i = n
    for _ in range(2*10**6):
        temp =  math.floor(a*i/b)-a*math.floor(i/b)
        if ans < temp:
            ans = temp
            # ans_i = i
        i += b
        if i >= n+1:
            # print('c-')
            print(int(ans))
            exit()
    print(int(ans))

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = [int(_n) for _n in input().split()]
if A == 1:
    print(0)
elif N >= B:
    print(A-1)
else:
    t = N
    print(floor(A*t/B) - A * floor(t/B))

Submission status: Wrong Answer

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

x = 0
max_score= -float('inf')
for x in range(N+1) :
    score = int(A*x/B) - A * int(x/B)
    if score > max_score:
        max_score = score
    else:
        break
print(max_score)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
start =  b // a
count = 0
for i in range(start,n+1):
    dum1 = (a * i / b) // 1
    dum2 = a * ((i / b)//1)
    dum3 = dum1 - dum2
    #print(dum1,dum2)
    ans = max(ans,dum3)
    count += 1
    if count > 10**6:
        break
print(math.ceil(ans))

Submission status: Wrong Answer

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

def f(t):
    return int(t)

Max_x=0

for i in range(N):
    if f(A*i/B)-A*f(i/B)<f(A*(i+1)/B)-A*f((i+1)/B):
        Max_x=i+1
        
print(f(Max_x))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

left, right = 0, n
while right > left + 10:
    mid1 = (right * 2 + left) / 3
    mid2 = (right + left * 2) / 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(int(left), int(right) + 1):
    listalt.append(f(i))
listalt.append(f(0))
listalt.append(f(n))
print(max(listalt))

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
cand2=0
if x>=0:
    cand2=floor(a*x/b)-a*floor(x/b)
x-=1
if x>=0:
    cand2=max(floor(a*x/b)-a*floor(x/b),cand2)

x2=n-1
cand3=floor(a*x2/b)-a*floor(x2/b)
if n-2>=0:
    x2=n-2
cand4=floor(a*x2/b)-a*floor(x2/b)
print(max(cand2,cand1,cand3,cand4))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
if x2 < 0:
    x2 =1
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)

print(max(f(x1), f(x2)))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
S = 0
n = N // B
r = N % B
if B > N:
    S = (A*N)//B
else:
    if  r == 0:
        S = (A*(N-1))//B - A * (N-1//B)
    elif r == B - 1:
        S = (A*N)//B - A * (N//B)
    else:
        S = (A*(n*B-1))//B - A * ((n*B-1)//B)

print(S)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y

if b > n:
    print(func(n))
else:
    print(func(b*((n//b)-1)+b-1))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
ans = -100000000000
if A >= B:
    if N >= A:
        print(A-2)
    else:
        for i in range(N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans < t :
                    ans = t
        print(ans)
else:
    if N >= A:
        print(A-1)
    else:
        for i in range(N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans < t :
                    ans = t
        print(ans)

Submission status: Wrong Answer

Solution code:
import math
# ~n,m,q  = map(int,input().split())

# ~seq = [-1]*n;

# ~qs = []
# ~for i in range(q):
	# ~a,b,c,d = map(int,input().split())
	# ~qs.append([a,b,c,d])
# ~qs = sorted(qs, key = lambda x :x[3], reverse = True)


# ~ans = 0

# ~for i in range(q):
	# ~if (seq[qs[i][0]-1] == -1 and seq[qs[i][1]-1] == -1):
		# ~seq[qs[i][1]-1] = qs[i][2]
		# ~seq[qs[i][0]-1] = 1
		# ~ans += qs[i][3]
	# ~else:
		# ~if (seq[qs[i][1]-1] - seq[qs[i][0]-1] == qs[i][2]):
			# ~ans += qs[i][3]
# ~print(ans)

	
	
# ~floor(Ax/B)−A×floor(x/B)

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

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

# ~x = math.ceil((1+2*b)/a)
# ~print(x)


# ~print(f(a,b,x))

print(math.floor(n/(b/a)))

Submission status: Wrong Answer

Solution code:
l = input().split()
a = float(l[0])
b = float(l[1])
n = int(l[2])
max = 0
calc = 0
calc1 = 0
calc2 = 0
calc3 = 0
for i in range(1, n+1):
  calc1 = a*i // b 
  calc2 = i // b
  calc3 = a * calc2
  calc = calc1 - calc3
  if max < calc:
    max = calc
print(int(calc))

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0

for x in range(1, A[2]+1):
  if i_max < ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    i_max = (A[0]*x//A[1]-A[0]*(x//A[1]))
    i_count = x
    if (x - i_count) == 1:
      j_count = j_count + 1
  if (j_count == 2):
    break
    
print(i_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A):
    x = B - i
    if x < 0:
        break
    tmp = int(( A * x % B - (A * x) % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

x = min(b, n)
ans1 = int(a * x / b)
if b == n:
    print(0)
elif b == 1:
    print(0)
else:
    print(ans1)

Submission status: Wrong Answer

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

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

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

    # 分母のBに注目すると、1 <= x <= B　を調べれば良い
    if B >= N:
        print(f(N))
    else:
        print(f(B))



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

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

    # さぶたん
    left, right = 1, N
    cnt = 500
    ans = 0
    while cnt > 0:
        cnt -= 1
        c1, c2 = (2*left+right)//3, (left+2*right)//3

        ret1, ret2 = f(c1), f(c2)

        if ret1 > ret2:
            ans = max(ans, ret1)
            right = c2
            continue
        elif ret1 < ret2:
            ans = max(ans, ret2)
            left = c1
            continue

    print(ans)




if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N

ans1 = (A * x//B) - A * (x // B)
ans2 = (A * N//B) - A * (N // B)

# ans = max(A-1, ans2)
if N < B:
    print(ans2)
else:
    print(A-1)
exit()
# exit()


# exit()
memo = [0] * (B+1)
ma = 0
for x in range(1, B+1):
    memo[x] = (A * (x)//B) - A * ((x)  // B)
    ma = max(memo[x], ma)
# print(memo[N-1])
print(memo)
# print(N)

# exit()
if N >= B:
    ans = ma
else:
    ans = memo[N]
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
result = []
for i in range(10**7):
    result.append((a*n)//b - a*(n//b))
    n -= 1
    if n < 0:
        break
print(max(result))

Submission status: Wrong Answer

Solution code:
import math
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])
N = int(tmp[2])
Mmax = 0

if N > B:
    ANS = math.floor(A*(B-1)/B)
else:
    ANS = math.floor(A*N/B)

print(int(ANS))

Submission status: Wrong Answer

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

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

ans = -10**9
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:
import math
a,b,n = map(int,input().split())

temp = a * b // math.gcd(a, b) - 1
temp = min(temp, n)
ans = (a * temp)//b - a * (temp//b)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
#"""
if N <= B:
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*(N-1)/B)-A*floor((N-1)/B)))
else:
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*B/B)-A*floor(B/B),floor(A*(B-1)/B)-A*floor((B-1)/B)))
#"""
#for x in range(100):
#    print(floor(A*x/B)-A*floor(x/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A, B, N = map(int,input().split())
x = min(B, N)
print(int(fun(A, B, x)))

Submission status: Wrong Answer

Solution code:
import math
import itertools
a,b,n = map(int,input().split())
pnt = 0
maxi = 0
if n>b:
    x = b-1
else:
    x = n

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

Submission status: Wrong Answer

Solution code:
import math

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

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

print(num)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
dic = {}
ans = floor(A*1/B) - A*floor(1/B)
dic[ans] = 1
for i in range(2, N+1):
    tmp = floor(A*i/B) - A*floor(i/B)
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
    if dic[ans] >= 2:
        break
for k, v in dic.items():
    ans = max(ans, k)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = [int(x) for x in input().strip().split(" ")]

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

Submission status: Wrong Answer

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

def F(x):
    return (a*x//b)-a*(x//b)

l=0
r=n+1
ans=0

for i in range(60):
    m=(r+l)//2
    f=F(m)
    #print(m,f,ans)
    if f>ans:
        ans=f
        l=m
    else:
        r=m
    
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def solve(A: int, B: int, N: int):
    max_b = 0
    for x in range(min(N+1,int(pow(1000000, 0.5)))):
        max_b = max(max_b, math.floor(A*(x/B-x//B)))
    print(max_b)

    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:
A,B,N=map(int,input().split())
b=B-1
ans=0
while b<=N:
    num=(A*b)//B-A*(b//B)
    if ans>=num:
        break
    else:
        ans=num
    b+=B
num=(A*(N-1))//B-A*((N-1)//B)
if ans<num:
    ans=num
print(ans)

Submission status: Wrong Answer

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

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

ans = -10**9
print(case)
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:
import numpy as np
import pprint

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = input().split(" ", 3)
a = int(a)
b = int(b)
n = int(n)
if(n >= b):
    print(a-1)
if(n < b):
    print(math.floor(a*(n)/b)-a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
import math

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

left, right = 0, n
while right > left + 10:
    mid1 = (right * 2 + left) / 3
    mid2 = (right + left * 2) / 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(int(left), int(right) + 1):
    listalt.append(f(i))
listalt.append(f(0))
listalt.append(f(n))
print(max(listalt))

Submission status: Wrong Answer

Solution code:
import math

def main():
    input1 = input().split()
    A = int(input1[0])
    B = int(input1[1])
    N = int(input1[2])

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

    print(output)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def target(x):
    return (A * x) // B - A * (x // B)


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

left = -1
right = N

while right - left > 1:
    mid = (left + right) // 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())
pmax=0
for i in range(1,n+1):
    p = i/b - i//b
    if pmax < p:
        pmax=p
        print(i,pmax)
print(int(pmax*a))

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 Bs-1 <= N:
    m = Bs - 1
else:
    m = N
print(floor(As * m / Bs) - As * floor(m / Bs))
# for x in range(1, N+1):
#     print(floor(As*x/Bs)-As*floor(x/Bs))