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:
from math import floor
a, b, n = map(int, input().split())
r = floor(n / b)
x = max(r * b - 1, 0)
max_x = floor(a * n / b) - a * floor(n / b)
for i in range(100000):
    if x > 0:
        max_x = max(max_x, floor(a * x / b) - a * floor(x / b))
        x -= b
    else:
        break
max_x = floor(a*(b-1)/b) - a* floor((b-1) / b)
print(max_x)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
def f(x, A, B):
    return math.floor(A*x / B)

if N >= B:
    print(A)
else:
    print(f(min([B-1, N]), A, B))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
 
C = N - N%B
ans = math.floor(A*(C-1)/B)-A*math.floor((C-1)/B)
if B > N:
  ans = math.floor(A*N/B) - A*math.floor(N/B)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

max=0
x_max=-1

tmp = math.floor(A*(B-1)/B)-A*math.floor((B-1)/B)
if tmp>=max:
	max=tmp
tmp = math.floor(A*N/B)-A*math.floor(N/B)
if tmp>=max:
	max=tmp
print(max)

Submission status: Wrong Answer

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

C = N - N%B
ans = math.floor(A*(C-1)/B)-A*math.floor((C-1)/B)
if B > N:
  ans = math.floor(A*N/B) - A*math.floor(N/B)
print(ans)

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 = 1
    return (f(x + h) - f(x - h)) / (2 * h)

def lr(step, max_step):
    return (N / 4 * 5 - 1) / max_step * step

def gradient_descent(f, initial, learning_rate=1, steps=10 ** 4):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for step in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= lr(step, steps + 1) * grad
        if x < 0:
            x = 0
        elif x > N:
            x = N

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(10 ** 2):
    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
from math import gcd
from math import ceil
k = gcd(A, B)

As = A // k
Bs = B // k

Q = min(N, B-1)
R = ceil(Bs / As)
res = []
for b in range(Q, Q - R, -1):
    res.append(floor(b*As/Bs) - As*floor(b/Bs))

print(max(res))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
m=0
if n>=(b-1):

    x=b-1
    m=int(a*x/b)-a*int(x/b)

else:
    for x in range(n):
        l=int(a*x/b)-a*int(x/b)

        if l>=m:

            m=l
print(m)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
score = 0
for i in range(N-1000000,N):
    x = i+1
    val = int(A*x/B) - A * int(x/B)
    #print( int(A*x/B) , A * int(x/B))
    if(val > score):
        score = val
print(score)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
score = 0
for i in range(N-100,N):
    x = i+1
    val = int(A*x/B) - A * int(x/B)
    #print( int(A*x/B) , A * int(x/B))
    if(val > score):
        score = val
print(score)

Submission status: Wrong Answer

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

if b-1<n:
    s=b-1
else:
    s=n

print((s*a//b)-a*(3//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
score = 0
for i in range(N-1,N):
    x = i+1
    val = int(A*x/B) - A * int(x/B)
    #print( int(A*x/B) , A * int(x/B))
    if(val > score):
        score = val
print(score)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
if n<b:
  print(int(a*n/b))
  exit()
t = int(a*(b-1))/b- int(a*(b-1)/b)
s = int(a*(b+1))/b- int(a*(b+1)/b)
q = int(a*(n))/b- int(a*(n)/b)
print(max(t,s,q))

Submission status: Wrong Answer

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

x=N
result=[]
maxr=0
for x in reversed(range(1,N+1)):
    xb=0 if x<B else x/B
    r=A*floor(xb)
    l=floor(A*xb)
    ans=l-r
    result.append(ans)
    if len(result) == 1:
        maxr = ans 
    if len(result) > 1 and max(result) == maxr:
        pass

print(max(result))

Submission status: Wrong Answer

Solution code:
a,b,n  = map(int, input().split())
N=[]
s=b-1
N.append((s*a//b)-a*(3//b))
s=n
N.append((s*a//b)-a*(3//b))
print(min(N))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
if n<b:
  print(int(a*n/b))
  exit()
if n<2*b:
  t = int(a*(b-1))/b- int(a*(b-1)/b)
  s = int(a*(b+1))/b- int(a*(b+1)/b)
  q = int(a*(n))/b- int(a*(n)/b)
  print(max(t,s,q))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

max=0
x_max=-1


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

Submission status: Wrong Answer

Solution code:
import math
ans=-100000000
a,b,n=map(int,input().split())
st=1
if n>1000000:
    st=b-1
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

Solution code:
li=list(input().split())
a=int(li[0])
b=int(li[1])
n=int(li[2])
ans=int(a*0/b)-a*int(0/b)
for x in range(b+1):
    s=int(a*x/b)-a*int(x/b)
    if s>ans:
        ans=s
print(ans)

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 lr(step, max_step):
    return (N / 4 * 5 - 1) / max_step * step

def gradient_descent(f, initial, learning_rate=1, steps=10 ** 4):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for step in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= lr(step, steps + 1) * grad

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(10**2):
    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:
# -*- coding: utf-8 -*-

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

if N > B:
    x  = B - 1
    z = (A * x) // B - A * (x // B)
else:
    x = N
    z = (A * x) // B - A * (x // B)

print(int(z))

Submission status: Wrong Answer

Solution code:
def nibutan(minval,maxval) :
    if maxval-minval<3 :
        return minval;
    elif (func(minval)-func((minval)//2+1))*(func((minval+maxval)//2+1)-func((minval+maxval)//2))<0 :
        return nibutan(minval,(minval+maxval)//2);
    else :
        return nibutan((minval+maxval)//2+1,maxval);

def func(x) :
    global a,b;
    return (a*x)//b-a*(x//b);

a,b,n = list(map(int,input().split()));
ans = nibutan(1,n);
print(max(func(ans),func(ans+1),func(ans+2)));

Submission status: Wrong Answer

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

else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
x1 = N
x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
def g(x): 
    s = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(s)
li = [f(x1), g(x3)]
print(max(li))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<=b:
    ans =f(n)
elif n==b:
    ans = max(f(n-1),f(n))
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
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(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
	
print(max)

Submission status: Wrong Answer

Solution code:
def nibutan(minval,maxval) :
    if maxval-minval<3 :
        return minval;
    elif (func(minval)-func((minval)//2+1))*(func((minval+maxval)//2+1)-func((minval+maxval)//2))<0 :
        return nibutan(minval,(minval+maxval)//2);
    else :
        return nibutan((minval+maxval)//2,maxval);

def func(x) :
    global a,b;
    return (a*x)//b-a*(x//b);

a,b,n = list(map(int,input().split()));
ans = nibutan(1,n);
print(max(func(ans-2),func(ans-1),func(ans),func(ans+1),func(ans+2)));

Submission status: Wrong Answer

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

if a <= b:
    if a > n:
        n_tmp = n
        ans = int(a*n_tmp/b) - a*int(n_tmp/b)
        print(ans)

    elif a == n:
        n_tmp = n-1
        ans = int(a*n_tmp/b) - a*int(n_tmp/b)
        print(ans)

    else:
        ans = a-1
        print(ans)

else:
    if a >= n:
        ans_max = 0
        n_tmp = n
        for x in range(n_tmp+1):
            ans = int(a*x/b) - a*int(x/b)
            #print(ans)
            if ans_max < ans:
                ans_max = ans
        print(ans_max)

    else:
        ans_max = 0
        n_tmp = a
        for x in range(n_tmp + 1):
            ans = int(a * x / b) - a * int(x / b)
            #print(ans)
            if ans_max < ans:
                ans_max = ans

        print(ans_max)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<=b:
    ans =f(n)
elif n==b:
    ans = f(n-1)
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans*a//b)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()

    p = b-1 if b-1 < n else n-1
    #print(p)
    print(floor(a*p/b) - a*floor(p/b))


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<=b:
    ans =f(n)
elif n==b:
    ans = f(n-1)
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    a, b, n = wi()
    print(min(int(a*(b-1)/b) - a*int((b-1)/b), int(a*(n/b)) - a*int(n/b)))
    """
    for i in range(1, b+1):
        print(int(a*i/b) - a*int(i/b))
        c.append(int(a*i/b) - a*int(i/b))
        if i >= b:
            break
    print(max(c))
    """


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def nibutan(minval,maxval) :
    if maxval-minval<3 :
        return minval;
    elif (func(minval)-func((minval)//2+1))*(func((minval+maxval)//2+1)-func((minval+maxval)//2))<0 :
        return nibutan(minval,(minval+maxval)//2);
    else :
        return nibutan((minval+maxval)//2,maxval);

def func(x) :
    global a,b;
    return (a*x)//b-a*(x//b);

a,b,n = list(map(int,input().split()));
ans = nibutan(1,n);
print(max(func(ans),func(ans+1),func(ans+2)));

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
score = 0
for i in range(A):
    x = i+1
    val = int(A*x/B) - A * int(x/B)
    #print( int(A*x/B) , A * int(x/B))
    if(val > score):
        score = val
print(score)

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 lr(step, max_step):
    return (N / 3 * 2 - 1) / max_step * step

def gradient_descent(f, initial, learning_rate=1, steps=10 ** 4):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for step in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= lr(step, steps + 1) * grad

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(10):
    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:
import sys

input = sys.stdin.readline
MOD = 1000000007

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


    

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

res = 0
for i in range(B-1,N):
    res = max(res,f(i))

print(res)



#if A == B:
#    x = A - 1
#    print(x)
#
#else:
#    res = 0
#    left = 0
#    right = N
#
#    left_res = 0
#    right_res = 0
#
#    while (left+1) != right:
#        left_res = f(left)
#        right_res = f(right)
#        mid = (right+left)//2
#        if left_res > right_res:
#            right = mid
#        else:
#            left = mid
#
#    print(max(f(left),f(right)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
N = min(N, pow(10, 8))
x = np.arange(min(N, B-1), N+1, B)
x = func(x)

# 結果出力
print(int(np.max(x)))

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(float,input().split())
if N >= B:
    N = N-1
ans = math.floor((A*N/B)) - A*math.floor(N/B)
print(int(ans))

Submission status: Wrong Answer

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

x = a*n//b
print(x-x//b*a)

Submission status: Wrong Answer

Solution code:
inp=input
li=list
iinp=lambda : int(inp())
ent=lambda : map(int,inp().split())
lient=lambda : [int(i) for i in inp().split()]
li0= lambda x: [0 for i in range(x)]
livalor=lambda valor,x: [valor for i in range(x)]
stent=lambda : [i for i in inp()]
filldp=lambda valor,x,y: [[valor for i in range(y)] for i in range(x)]
ma=max

from math import floor as f

a,b,n=ent()
res=0
for i in range(n,1,-1):
    tmp=f(a*i/b)-a*f(i/b)
    if tmp>=res:
        res=tmp
    else:
        break
print(res)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
x1 = N
x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
li = [f(x1), f(x3)]
print(max(li))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
def func(x):
    return int((A*x)/B) - A * int(x/B)
 
if N < B:
    print(func(N))
else:
    print(B-1)

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    A, B, N = lr()
    if B == 1:
        print(0)
        return
    if A%B == 0:
        if N%B == 0 and N == 1:
            print(0)
            return
        else:
            if N//B == 0:
                print((A*N)//B)
                return
            else:
                print(A)
                return
    if N%B == 0 and N == 1:
        print(0)
        return
    if N//B == 0:
        print((A*N)//B)
        return
    print(A)
resolve()

Submission status: Wrong Answer

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

x = a*n//b
print(x-x//b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
res=0
x=n
for x in range(min(100000000,b,n+1)):
    res=max(res,int(a*x/b)-a*int(x/b))
res=max(res,int(a*n/b)-a*int(n/b))    
print(res)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
x1 = N
x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
print(max(f(x3), f(x1)))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
if B > N:
    print(int(A*N/B))
else:
    work = A
    for x in range(B, N + 1, 1):
        if work < int(A*x/B)-A*int(x/B):
            work = int(A*x/B)-A*int(x/B)
    print(work)

Submission status: Wrong Answer

Solution code:

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

nb=n//b

xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
    for xb in range(nb):
        xv=(a*xb*b+a*(b-1))//b-a*xb
        xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
 
def f(x):
    return int(A*x/B)-A*int(x/B)
 
X = N
Y = min(B-1,N)
 
print(max(f(X),f(Y)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
res=0
x=n
for x in range(min(1000001,b,n+1)):
    res=max(res,int(a*x/b)-a*int(x/b))
res=max(res,int(a*n/b)-a*int(n/b))    
print(res)

Submission status: Wrong Answer

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

A, B , N=  [int(i) for i in input().split()]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


def main():
    a,b,n = map(int,input().split())
    m = math.floor(a * 0 /b) - a * math.floor(0/b)
    for i in range(1,min(b-1,n)+1):
        if m < math.floor(a * i / b) - a * math.floor(i/b):
            m = math.floor(a * i / b) - a * math.floor(i/b)
            break
    print(m)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    A, B, N = lr()
    if B == 1:
        print(0)
        return
    if A%B == 0:
        if N%B == 0 and N == 1:
            print(0)
            return
        else:
            print(A)
            return
    if N%B == 0 and N == 1:
        print(0)
        return
    if N//B == 0:
        print((A*N)//B)
        return
    print(A)
resolve()

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
if B > N:
    print(int(A*N/B))
else:
    work = A
    for x in range(B, N, 1):
        if work < int(A*x/B)-A*int(x/B):
            work = int(A*x/B)-A*int(x/B)
    print(work)

Submission status: Wrong Answer

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

A, B , N=  [int(i) for i in input().split()]

if B-1 >= N:
    print(min(int(A*N/B) - A*int(N/B), int(A*(B-1)/B) - A*int((B-1)/B) ))
else:
    print(max(int(A*N/B) - A*int(N/B),0))

Submission status: Wrong Answer

Solution code:
A, B, N= map(int, input().split())
score=0
max_score=0
for i in range(N):
    score=(A*(i+1)//B)
    if max_score<score:
        max_score=score
print(max_score)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
x = 0
loop1 = n//b + 4
if loop1 > 10**5:
    loop1 = 10**5
    
loop2 = n//a + 4
if loop2 > 10**5:
    loop2 = 10**5

max_ = 0
    
if n < 10**8:
    for x in range(1, n + 1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

else:
    for x in range(1, 10**5):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
    
    for x in range(n - 10**5, n):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
            
    for i in range(1, loop1):
        x = i*b - 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

    for i in range(1,loop2):
        x = i*b//a + 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        print((a*x)//b,a*(x//b), tmp)
        if tmp > max_:
            max_ = tmp
    
print(max_)

Submission status: Wrong Answer

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<=b:
    ans =f(n)
else:
    t = n
    u = min(b - 1,n)
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
import copy
s = input().split()
A = int(s[0])
B = int(s[1])
N = int(s[2])
s = 0

if B > N:
	for i in reversed(range(N+1)):
		y = int(A * i / B) - A * int(i / B)
		# print(y)
		if s <= y:
			s = copy.copy(y)
			break
		else:
			break
else:
	for i in reversed(range(B+1)):
		y = int(A * i / B) - A * int(i / B)
		# print(y)
		if s <= y:
			s = copy.copy(y)
			break
		else:
			break

print(s)

Submission status: Wrong Answer

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

print(a*n//b)

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
    ans = floor(a*m/b)-a*floor(m/b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
if B==1:
    print(0)
elif A==1:
    print(0)
elif N%B!=0:
    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:
import math
A,B,N=map(float,input().split())
if B==1 or A==1:
    ans = 0
else:
    while N%B==0:
        N = N-1
    ans = math.floor((A*N/B)) - A*math.floor(N/B)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math


def main():
    a,b,n = map(int,input().split())
    m = math.floor(a * 0 /b) - a * math.floor(0/b)
    for i in range(1,b):
        if m < math.floor(a * i / b) - a * math.floor(i/b):

            m = math.floor(a * i / b) - a * math.floor(i/b)
    print(m)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
def f(x, A, B):
    return math.floor(A*x / B)

if N >= B:
    print(A)
else:
    print(f(min(B-1, N), A, B))

Submission status: Wrong Answer

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

x=N
result=[]
result.append(floor(A*x/B)-A*floor(x/B))
x=1
result.append(floor(A*x/B)-A*floor(x/B))

print(max(result))

Submission status: Wrong Answer

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

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

if N >=  B:
    x = B
    z = (A * x) // B - A * (x // B)
else:
    x = N
    z = (A * x) // B - A * (x // B)

print(int(z))

Submission status: Wrong Answer

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

x1 = N
x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
print(max(f(x1),f(x3)))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split(" "))
ans = 0
x = B-1
if B-1 < N:
    floor = int(A*x/B) - A * int(N/B)
else:
    floor = int(A*N/B)
print(floor)

Submission status: Wrong Answer

Solution code:
import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<=b:
    ans =f(n)
else:
    t = n
    u = b - 1
    ans=max(f(t),f(u))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
def f(x, A, B):
    return A*x // B

if N >= B:
    print(A)
else:
    print(f(min(B-1, N), A, B))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
if B > N:
    print(A)
else:
    work = A
    for x in range(B, N, 1):
        if work < int(A*x/B)-A*int(x/B):
            work = int(A*x/B)-A*int(x/B)
    print(work)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
count = 0
Score = list()
i = 1
while True:
  score = math.floor((A*i)/B) - A * math.floor(i/B)
  Score.append(score)
  if score < max(Score):
    count += 1
  if count ==10:
    break
  i += 1
print(max(Score))

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
X=[]
for x in range(N):
    X.append(abs(math.floor(A*x/B)-A*math.floor(x/B)))
print(max(X))

Submission status: Wrong Answer

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

x1 = N
x3 = min(N,B-1)
def f(x): 
    t = math.floor((A*x)/B) - A * math.floor(x/B)
    return int(t)
print(max(f(x1),f(x3)))
print(max(3,3,2))

Submission status: Wrong Answer

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

print(min(b-1, n))