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
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

def LII_split():
    return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

# def numerical_diff(f, x):
#     """中央差分を元に数値微分する関数"""
#     h = 1e-4
#     return (f(x + h) - f(x - h)) / (2 * h)
#
# def gradient_descent(f, initial, learning_rate=1, steps=10):
#     """一階導関数から勾配法で最小値を求める関数"""
#     # 現在地を示すカーソル
#     x = initial
#
#     # 所定の回数を繰り返す
#     for _ in range(steps):
#         # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
#         grad = numerical_diff(f, x)
#         # 勾配を元にして現在地を移動する
#         x -= learning_rate * grad
#
#     # 最終的な位置を返す
#     return f(x)

ma = 0
for _ in range(int(1.5*10 ** 6)):
    ini = random.randrange(N + 1)
    # tmp = gradient_descent(f, ini)
    tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

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

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)
x2=n-1
cand3=floor(a*x2/b)-a*floor(x2/b)
print(max(cand2,cand1,cand3))

Submission status: Wrong Answer

Solution code:
import math

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


ans1 = 0
if B > N:
    x = 0
    while x <= N and x <= A:
        ans = int((A * x) / B) - A * int(x / B)
        ans1 = max(ans1, ans)
        x += 1
    print(ans1)

else:
    x = N
    while x > A and x <= B:
        ans = int((A * x) / B) - A * int(x / B)
        ans1 = max(ans1, ans)
        x -= 1
    print(ans1)

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 = min(n, 0)
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))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if b>=n:
	ans=(a*n)//b
	print(ans)
else:
	ans=(a*(b-1)//b)
	print(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)
if N >= B-1:
    print(B-1)
else:
    print(N*A//B)

Submission status: Wrong Answer

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

def fl_m(a,b,n):
  if n>b:
    z=a-1
  elif n==b and b/a>=1:
    z=a-1
  elif n==b and b/a<1:
    z=a-2
  else:
    k=int(n*a/b)
    z=k
  return(z)
    
print(fl_m(A,B,N))

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 b >= 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:
import math

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

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N == max(A, B, N):
    ans = math.floor((A*N)/B)-A*(N//B)
else:
    if N <= 1000000:
        for x in range(1, N+1):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(1, 300000):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)

        base = N//2-150000
        for x in range(base, base+300000):
            tmp = math.floor((A*x)/B)-A*(x//B)
            ans = max(ans, tmp)

        for x in range(N-300000, N+1):
            tmp = math.floor((A*x/B))-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
for i in range(n,-1,-1):
    ans = a*i//b-a*(i//b)
    al.append(ans)
    if len(al) > 1:
        if al[-1] <= al[-2]:
            break
print(max(al))

Submission status: Wrong Answer

Solution code:
from math import floor

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

x = None
if N < B:
    x = N
else:
    x = 1
    max_diff = 0
    for _x in range(N + 1):
        diff = (x / B) - floor(x / B)
        if max_diff <= diff:
            max_diff = diff
            x = _x

answer = floor(A * x / B) - A * floor(x / B)

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cand = []

def calc(n):
  return int(a*n/b)-a*int(n/b)

cand.append(calc(0))
cand.append(calc(1))
cand.append(calc(n))
cand.append(calc(n-1))
cand.append(calc(b*(n//b)))
cand.append(calc(max(0, b*(n//b) - 1)))
cand.append(calc(b-1))

print(max(cand))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = N-1
else:
  x = N
ans = math.floor(A*x/B)-A*math.floor(x/B)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

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

    def bin(a):
        left = -1
        right = A + 1

        while(right-left > 1):
            mid = (right+left) / 2
            x = c(mid)
            if x == a:
                return mid
            elif x < a:
                left = mid
            else:
                right = mid

        return -1


    for _a in range(A+1):
        a = A - _a
        x = bin(a)
        # print(x,c(x),a)
        if 0<=x<=N:
            print(a)
            exit()


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
pp =False
t =0
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if tmp != 0:
        pp =True
    if tmp == 0:
        if sec ==True and pp ==True:
            break
        elif pp ==False and sec ==True:
            t = math.ceil(B/2)-1
            maxn = math.floor((A*t)/B)-A*(math.floor(t/B))
            break
        sec =True
    
print(maxn)

Submission status: Wrong Answer

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)

    if A >= 100000:
        for i in range(0,1000):
            ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)
    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
d = [0]
x = 0
for i in range(N+1):
    C = math.floor(A*x/B)
    D = math.floor(x/B)
    ans = C-A*D
    d.append(ans)
    if d[i] < d[i+1]:
        break
    x += 1
print(max(d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if b < n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)

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

Submission status: Wrong Answer

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

ans = -1
if(n>10**6):
    for x in range(n-int(n**(1/2))-1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Wrong Answer

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

if n % 2 == 0:
  print(math.floor((a * (n-1) / b)) - (math.floor((n-1) / b) * a))
elif n % 2 == 1:
  print(math.floor((a * n / b)) - (math.floor(n / b) * a))

Submission status: Wrong Answer

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

if N >= B:
    print(A-1)

else:
    #ans = math.floor(A*N/B) - A*math.floor(N/B)
    ans = (A*N)/B
    print(int(ans))

Submission status: Wrong Answer

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

tmp = 0
for x in (range(1, b+1, b) if b<=n else range(1, n+1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc

print(tmp)

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
list = []

if N >= 10000:
    for i in range(N-10000,N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Wrong Answer

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

for x in range(0,n+1):
  c=int((a*x)/b)
  d=int(x/b)
  e=int(c-a*d)
  list=[]
  list.append(e)
  
print(max(list))

Submission status: Wrong Answer

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

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

print(ans)

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)
input = sys.stdin.buffer.readline
INF = float("inf")

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


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


left = 1
right = n

count = 0
while count < 10000:
    count += 1
    mid_left = left + (right - left) / 3
    mid_right = right - (right - left) / 3
    # print(left, right)
    # print(mid_left, mid_right)
    if func(mid_left) > func(mid_right):
        right = mid_right
    else:
        left = mid_left


ans1 = func(math.floor(left))
ans2 = func(math.ceil(left))
ans3 = func(math.floor(right))
ans4 = func(math.ceil(right))

# print(left, right)
# print(ans1, ans2)

if n == 1:
    print(func(1))
else:
    print(max(ans1, ans2, ans3, ans4))

Submission status: Wrong Answer

Solution code:
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(0,min(a+1,n+1)):
        left = int(a*x//b)
        right = a * int(x//b)
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = 0
# for i in range(1, N+1):
#     temp = int((A*i)/B)-A*int(i/B)
#     if temp > ans:
#         # print(i)
#         ans = temp

print(int((A*N)/B)-A*int(N/B))

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())
ans = math.floor(A*N/B) - A*math.floor(N/B)
if N >= B:
    ans = max(ans, math.floor(A*B/B) - A*math.floor(B/B))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

if A*N < B:
    print(0)
    exit()

if N < B:
    print(int((A*N)/B) - A*int(N/B))
    exit()

aa = N//B
if 10**8 < aa:
    x = aa*B - 1
    print(int((A*N)/B) - A*int(N/B))
    exit()

#x = aa*B - 1
res = 0
for i in range(1, aa+1):
    x = i*B - 1
    cres = int(A*x/B) - A*int(x/B)
    if res < cres:
        res = cres

print(res)

Submission status: Wrong Answer

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

Answer = abs(floor((A*N)/B) - A*floor(N/B))
print(Answer)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math

def has_duplicates(seq):
    return len(seq) != len(set(seq))

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 has_duplicates(List)==True:
        break
    #print(ans)
    i+=1
#print("ans")
print(max(List))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = 0
if n < b:
    ans = max(ans, a*n//b)
else:
    ans = max(ans, (a*(b*2-1))//b - a)
    li = [1, (1+(n//b))//2, -(-(1+(n//b))//2)]
    for i in li:
        check = (a*(b*(i+1)-1))//b - a*i
        ans = max(ans, check)
    ans = max(ans, (a*n)//b)-a*(n//b)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
if N <= B:
    print(floor(A*N/B)-A*floor(N/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:
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(fun(A, B, x))

Submission status: Wrong Answer

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
l=calc(1)
l_num=1
r=calc(n)
r_num=n
mid=int((1+n)/2)
num=calc(mid)
while not(l<=num and num>=r):
    #print(str(l_num)+" "+str(mid)+" "+str(r_num))
    if l<num:
        l_num=mid+1
        mid=int((l_num+r_num)/2)
        l=calc(l_num)
        num=calc(mid)
    elif num>r:
        r_num=mid-1
        mid=int((l_num+r_num)/2)
        r=calc(r_num)
        num=calc(mid)
    if mid==l_num:
        num=calc(r_num)
        break
    if mid==r_num:
        num=calc(l_num)
        break
print(num)

Submission status: Wrong Answer

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

if N > B:
    x = B - 1
else:
    x = N
for a in range(1, A):
    if int(x/B + a/A) - int(x/B) != 0:
        result += 1

print(result)

Submission status: Wrong Answer

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

a1 = math.floor(a*-10**-12/b)-a*math.floor(-10**-12/b)
a2 = math.floor(a*n/b)-a*math.floor(n/b)

first = True
for i in range(1, n+1):
    if first and math.floor(a*i/b)-a*math.floor(i/b) != 0:
        first = False
    elif not first and math.floor(a*i/b)-a*math.floor(i/b) == 0:
        print(a1)
        break
else:
    print(a2)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    # for i in range(n, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    # if n // b * b - 1 >= 0:
    if b <= n:
        n = n // b * b - 1


    # while 1:
    #     if (a * n) % b == 0 and n % b == 0:
    #         n -= 1
    #     else:
    #         break


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

    # print('ans')
    # print(n, ans)
    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

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

answer = 0
if b-1 > n:
    answer = (a*n)//b - a*(n//b)
else:
    x = b-1
    while x < n:
        answer = max(answer, (a*x)//b - a*(x//b))
        x += b-1
    x = (n // (b-1)) * (b-1)

print(answer)

Submission status: Wrong Answer

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

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

print(ma)

Submission status: Wrong Answer

Solution code:
A, B, N = input().split()
A = float(A)
B = float(B)
N = float(N)
import math
max = 0
x = B-1
while x <= N:
  a = math.floor(A*x/B)-A*math.floor(x/B)
  if a > max:
    max = a
print(str(max))

Submission status: Wrong Answer

Solution code:
# Code for D - Floor Function
# Use input() to fetch data from STDIN
from math import floor
from decimal import Decimal

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

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

print(min(f(-1), f(n)))

Submission status: Wrong Answer

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

tmp = 0
for x in (range(1, b+1, b) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc

print(tmp)

Submission status: Wrong Answer

Solution code:
def check(A, B, mid):
    return (A * mid // B) - A * (mid // B)


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

    ans = 0
    ok = 0
    ng = min(N, B) + 1

    while abs(ok - ng) > 1:
        mid = (ng + ok) // 2
        tmp = check(A, B, mid)

        if ans < tmp:
            ok = mid
            ans = tmp
        else:
            ng = mid

    print(ans)


resolve()

Submission status: Wrong Answer

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

print(math.floor(A * N / B))

Submission status: Wrong Answer

Solution code:
A, B, N = 11, 10, 25
max_val = 0
if N < B:
    print(int(A*N/B))
else:
    for i in range(B-1, N, B):
        val = int(A*i/B) - A*int(i/B)
        flag = val > max_val
        if val > max_val:
            max_val = val
        if not flag:
            break

    print(max_val)

Submission status: Wrong Answer

Solution code:
#!python3

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


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


def main():
    if N < B:
        ans = f(N)
        print(ans)
        return
    
    l = []
    l.append(f(0))
    l.append(f(1))
    l.append(f(B))
    l.append(f(B - 1))
    l.append(f(N // B * B - 1)) 
    l.append(f(N - 1))
    l.append(f(N))

    ans = max(l)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N =  map(int,input().split())
ans = set()
for x in range(1,N+1):
    cal = math.floor(A*x/B)-A*math.floor(x/B)
    if cal in ans:
        break
    else:
        ans.add(cal)
print(max(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

left, right = 0, n
while right > left + 10:
    mid1 = int((right * 2 + left) / 3)
    mid2 = int((right + left * 2) / 3)
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(left, 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
a,b,c=[int(_) for _ in input().split()]
k=c-1
s=math.floor((k*a)/b)-a*math.floor(k/b)
t=math.floor((c*a)/b)-a*math.floor(c/b)
print(max(s,t))

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)
    case = [a,b,c,max(min(B-1,N),1)]

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

print(ans)

Submission status: Wrong Answer

Solution code:
# ABC165c


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())
    last = -1
    ans = -1

    def evaluate(number):
        return floor(a*number/b)-a*floor(number/b)

    for i in range(n, 0, -1):
        t = evaluate(i)
        ans = max(ans, t)
        #print(i, t)
        if t <= last:
            break
    print(ans)


if __name__ == '__main__':
    main()

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*(N-1))//B) - A*math.floor(((N-1)//B)))

Submission status: Wrong Answer

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

if N < 2*10**6:
    for x in range(N+1):
        ans = max(ans,(A*x//B)-A*(x//B))
else:
    for x in range(10**6+2):
        ans = max(ans,(A*x//B)-A*(x//B))
    for x in range(N,N-10**6,-1):
        ans = max(ans,(A*x//B)-A*(x//B))
print(ans)

Submission status: Wrong Answer

Solution code:
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1
x = 1

while True:
    score = math.floor(a*x/b) - a* math.floor(x/b)
    if max_score < score:
        max_score = score
        x += 1
    elif x > n:
        break

print(max_score)

Submission status: Wrong Answer

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

a,b,n = map(int,input().split())
max = floor(a,b,n)
for i in range(1,1000):
    if n < i:
        break
    if max < floor(a,b,n-i):
        max = floor(a,b,n-i)
print(max)

Submission status: Wrong Answer

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

temp_prev = 0
temp_curr = 0
if b <= 100:
    x = 0.0
else:
    x = b - 100.0

while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr < temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Wrong Answer

Solution code:
N = [int(e) for e in input().split()]
t = N[2]
ans = (N[0]*N[2])//N[1] - N[0]*(t//N[1])
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if (B<=N):
    print(A*N//B)
else:
    c=(A*N)//B-A*(N//B)
    d=(A*B)//B-A
    print(max(c,d))

Submission status: Wrong Answer

Solution code:
import math

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

var = N//B
ans = -1

if var != 0:
    for i in range(N, -1, -B):
        tmp = math.floor(A*i/B) - A*math.floor(i/B)
        ans = max(ans, tmp)
else:
    ans = max(0, 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 = set()
start = B - 1

for i in range(1, N + 1, B):
  ans.add(int(i * A / B) - A * int(i / B))
  
print(max(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 b >= 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 <= 0:
            # print('c-')
            print(int(ans))
            exit()
    print(int(ans))

Submission status: Wrong Answer

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

for i in range(1,N+1):
    t = math.floor(A*i/B)-math.floor(i/B)*A
    d.append(t)
    if N+1 > B:
        break
print(max(d))

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = list(map(int, input().split(' ')))
    N %= B
    n = 0
    while B * (n + 1) <= A * N:
        n += 1
    print(n)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0

k=n//b
if k>0:
	j=b
else:
	j=n

for i in range(min(a,j)):
	cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

ans = 0

for i in range(1,n+1):
    tmpans = int(a*i/b) - int(i/b)
    if tmpans >= ans:
        ans = tmpans

print(ans)

Submission status: Wrong Answer

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

def fl_m(a,b,n):
  if n>b:
    z=a-1
  if n==b and b/a>=1:
    z=a-1
  if n==b and b/a<1:
    z=a-2
  else:
    k=int(n*a/b)
    z=k
  return(z)
    
print(fl_m(A,B,N))