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(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())

#ans = 0
#for x in range(1, N+1):
#    total = ((A * x) // B) - A * (x // B)
#    print(x, total)
#print(ans)
print(((A * N) // B) - A * (N // B))

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

Submission status: Wrong Answer

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

def calc(x):
    # print(a, b, x)
    return (a*x)//b - a*(x//b)

# for i in range(n + 1):
#     print(calc(i))

print(calc(n))

Submission status: Wrong Answer

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

row, up = n-b, n
while row <= up:
    mid = (row+up)//2
    if n//b == mid//b:
        up = mid-1
    elif n//b > mid//b:
        row = mid+1
if int(a*(up)/b)-a*int((up)/b) > int(a*(n)/b)-a*int((n)/b):
    print(int(a*(up)/b)-a*int((up)/b))
else:
    print(int(a*(n)/b)-a*int((n)/b))

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)

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

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
a, b, n = int(arr[0]), int(arr[1]), int(arr[2])
if b<=n:
  k = a
else:
  k = (a*((n-1)))//b
print(k)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
max=0
xlist=[]
def bigger(a,b):
    if a > b:
        return a
    else:
        return b
for i in range(int(n/b)+1):
    xlist.append(bigger(n,i*b-1))
for x in xlist:
    if max < int(a*x/b)-a*int(x/b):
        max=int(a*x/b)-a*int(x/b)
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# for i in range(n+1,n-2*a,-1):
for i in range(2*a):
    ans = max(ans,int((a*i)/b) - a*int(i/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:
            x = (right+left) / 2
            if c(x) < a:
                left = x
            else:
                right = x

        return right


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


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

# process
x = 0
if B <= N:
    x = B-1
else:
    x = N

# output
print(x)
print(A*x//B - A*(x//B))

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

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

Submission status: Wrong Answer

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

def fl(i):
  return ((A * i) // B) - (A * (i // B))

i = 1
j = [0, N]
while i > 0:
  s = fl(j[0])
  t = fl(j[1])
  if t > s:
    j[0] = (j[1] - j[0]) / 2 + j[0]
  elif t < s:
    j[1] = (j[1] - j[0]) / 2 + j[0]
  else:
    m = (j[1] - j[0]) / 4 + j[0]
    n = (j[1] - j[0]) * 3 / 4 + j[0]
    if m > n:
      j[1] = (j[1] - j[0]) / 2 + j[0]
    else:
      j[0] = (j[1] - j[0]) / 2 + j[0]
    
  if j[1] - j[0] < 0.1:
    break

x = int(fl(j[0] // 1))
y = int(fl(j[1] // 1))
print(max(x, y))

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
if B == 1:
    max = 0
elif B >= N:
    x = N
    max = ((A * x) // B) - A * (x // B)
else:
    if (B * (N//B + 1) - 1) == N:
        x = N
    else:
        x = B * (N // B) -1
    max = ((A * x) // B) - A * (x // B)
print(max)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
if B>=N:
    for i in range(0,10**6):
        x=N-i+100
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)
elif B<N:
    for i in range(0,10**6):
        x=N+100-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    for i in range(0,10**6):
        x=B+100-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)

Submission status: Wrong Answer

Solution code:
def cal(i):
    return floor(a*i/b)-a*floor(i/b)
from  math import floor
a, b, n = map(int, input().split())
ans = 0
if b-1<n:
    ans = cal(b-1)
print(max(ans,cal(n),0))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if b > n:
    if b%n !=0:
        ans = math.floor(a*n/b) - a*math.floor(n/b)
    else:
        n -= 1
        ans = math.floor(a*n/b) - a*math.floor(n/b)
    print(ans)
    exit()

c = (n//b)*b-1
temp1 = math.floor(a*c/b) - a*math.floor(c/b)#一番大きい倍数の前
temp2 = math.floor(a*n/b) - a*math.floor(n/b)#とれる最大のｎ

print(max(temp1,temp2))

Submission status: Wrong Answer

Solution code:
A,B,N =map(int,input().split())
ans =int(A/B)-A*int(1/B)
i=2
while True:
    if int((A*i)/B)-A*int(i/B) > ans:
            ans =int(A*i/B)-A*int(i/B)
            i+=1
    else:
        print(i-1)
        break

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

Submission status: Wrong Answer

Solution code:
from math import floor
a,b,n = map(int,input().split())
ans = 0
if n <= b:
    for i in range(n):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
else:
    for i in range(1,n+1,b):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
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 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 sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

import math

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

max_score = 0

x = N
while B > x > 0:
    score = math.floor(A * x / B) - A * math.floor(x / B)
    max_score = max(score, max_score)
    x -= 1

print(max_score)

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    a,b,n  = map(int, input().split())
    maemax=math.floor(a*n/b)
    ushiromax=math.floor(n/b)
    i=math.floor(maemax*b/a)-1
    j=math.floor(ushiromax*b)-1
    if j<=i:
        print(maemax-a*ushiromax)
    else:
        print(math.floor(j*a/b)-a*math.floor(j/b))
resolve()

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,10):
    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:
import bisect  # 二分探索の公式のライブラリをimportする
# A, B, N = map(int, input().split())
# ans = (int(A*N/B) - A*int(N/B))
# # シミュレーション
# for i in range(max(N-1000005, 0), N+1):
#     ans = max(ans, int(A*i/B)-A*int(i/B))
# print(ans)


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

l = 0  # 最初の下界
r = N+1  # 最初の上界
ans = 0
while r - l > 1:  # rとlが交わることがあれば終了
    mid = (l+r) // 2  # 中央値, 選ぶ候補になっている値
    tmp = int(A*mid/B) - A*int(mid/B)
    if tmp >= ans:
        ans = tmp
        l = mid  # 下界をあげる
    else:
        r = mid  # 上界を下げる
    # print(l, r)
# print(l, r)
print(max(ans, int(A*N/B)-A*int(N/B), int(A*l/B)-A*int(l/B), int(A*min(N, r)/B)-A*int(min(N, r)/B)))

Submission status: Wrong Answer

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

max_v = 0
for x in range(n+1):
    v = math.floor(a*x/b) - a * math.floor(x/b)
    max_v = max(v, max_v)

Submission status: Wrong Answer

Solution code:
import math

A, B, N= (int(x) for x in input().split())
max = 0
x = B * math.floor(N/B) - 1
if x == -1:
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)
d = int(N/B)
e = int(A*N/B)

max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(d-k,d+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(e-k,e+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x				

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Wrong Answer

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 343000000:
    break

print(1)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

a,b,n = map(int, input().split())
print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Wrong Answer

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

ans = -1
if(n>100):
    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:
A,B,N= map(int,input().split())
ans = 0
shosu = 1/B
for x in range(N):
    y=int(A*x*shosu)-A*int(shosu)
    if ans < y:
        ans =y
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))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
A,B,N = map(int,input().split())
if B>N:
    ans = int(A*N/B)
    print(ans)
else:
    c = A // B
    ans = A-c-1
    print(ans)

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:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

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

def solve(a,b,n):
	x = n-1
	if(b > n):
		x = n
	return floor(a*x/b)


a,b,n = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b,n)
print(ans)

Submission status: Wrong Answer

Solution code:


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

max_ = -A
A*N
if B < N:
    max_ = int((A*N)/B) - A * int(N/B)
else:
    for x in range(N+1):
        num = int((A*x)/B) - A * int(x/B)
        if num > max_:
            max_ = num

print(max_)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
s=0
x=1
mf=math.floor
while True:
    q=mf(A*x/B)-A*mf(x/B)
    if s<=q:
        s=q
        #print(q)
        x=x+1
        continue
    if s>q:
        print(s)
        break

Submission status: Wrong Answer

Solution code:
import math
a, b, n = list(map(int,input().split()))
if b > n:
    print(math.floor(a*n/b))
elif n < 2*b - 1:
    print(math.floor(a*n/b)-a)
else:
    print(a+math.floor((-1)*a/b))

Submission status: Wrong Answer

Solution code:
a,b,N=map(int,input().split())
for i in range(0,100000000000000000000000000000000000000000000000000):
    d=((a*i)//b)-(a*(i//b))
    if(i>N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break

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 > 4:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    if mid_left == mid_right:
        break
    # print("func", func(mid_left), func(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(int(left), math.ceil(right)+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))
if N < 5:
    for i in range(2, N + 1):
        a = math.floor(((A * i) / B)) - A * math.floor((i / B))
        if res < a: res = a
else:

    for i in range(N - 5, N + 1):
        a = math.floor(((A * i) / B)) - A * math.floor((i / B))
        if res < a: res = a
print(res)

Submission status: Wrong Answer

Solution code:
def cal(i):
    return floor(a*i/b)-a*floor(i/b)
from  math import floor
a, b, n = map(int, input().split())
ans = 0
if b-1<n:
    ans = cal(b-1)
print(max(ans,cal(ans),cal(n),0))

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int,input().split())
 
if (N > 1):
	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)))
else:
	print(math.floor((A*1)//B) - A*math.floor((1//B)))

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, min(B-1,N)]
else:
    c = max(1,k*B//A)
    case = [a,b,c,min(B-1,N)]

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

A, B, N= (int(x) for x in input().split())
max = 0
x = B * math.floor(N/B) - 1
if x == -1:
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
print(math.floor(A * x / B))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(ceil(ceil(a*c/b)-a*floor(c/b)))

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

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=c-a*d
  list=[]
  list.append(e)
  
print(max(list))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
x = math.gcd(N,B)
K = math.floor(N/B)
if K == 0:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    alpha = B*(K+1)
    if alpha > N:
        alpha = N
    print(math.floor(alpha/B)-A*math.floor(alpha/B))

Submission status: Wrong Answer

Solution code:
import numpy as np

def fLOOR(a,b,x):
    return np.floor(a * x / b) - a * np.floor(x / b)
"""
def fLOOR1(a,b,x):
    return np.floor(a * x / b)

def fLOOR2(a,b,x):
    return np.floor(x / b)
"""
def main():
    a,b,n = map(int, input().split(" "))
    
    """
    for x in range(n):
        x += 1
        val = fLOOR(a,b,x)
        val1 = fLOOR1(a,b,x)
        val2 = fLOOR2(a,b,x)
        print(val)
    """
    if b <= n:
        ans = fLOOR(a,b,b-1)
    else:
        ans = fLOOR(a,b,n)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 343000000:
    break

print(mx)

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):
            tmp = math.floor((A*x/B))-A*(x//B)
            ans = max(ans, tmp)
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())
ans = 0
for i in range(100000):
    s = math.floor(a * i / b)
    t = math.floor (i/b)
    ans = max(ans,s - a*t)     
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

#for x in range(n+1):
ans = (math.floor((a*(n))/b) - (a * math.floor(n/b)))
if ans == 0:
    print(0)
else:
    print(math.floor(ans))

#print(max(li))

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    a,b,n  = map(int, input().split())
    maemax=math.floor(a*n/b)
    ushiromax=math.floor(n/b)
    i=math.floor(maemax*b/a)-1
    j=math.floor(ushiromax*b)-1
    if j<=i:
        print(maemax-ushiromax)
    else:
        print(math.floor(j*a/b)-a*math.floor(j/b))
resolve()

Submission status: Wrong Answer

Solution code:
import math


def main():
    A, B, N = list(map(int, input().split(' ')))
    N %= B
    print(math.floor(A * N / B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B > N / 2:
    num = reversed(range(1, N + 1))
else:
    num = range(1, N + 1)

for x in num:
    value = int(A * x / B) - A * int(x / B)
    if answer <= value:
        answer = value
    
    if x == B:
        break

print(answer)