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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
if N / B >= 1:
    print(A - 1)
else:
    print(math.floor(A * N / B) - A * math.floor(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 >= 8: 
    for i in range(0,1000000):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
    for i in range(N-10**6-10**5,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(floor((A*i)/B)-A*floor(i/B),maxi)
print(max(maxi,0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l = []
for x in range(10000):
    Z = (A * x) // B - A * (x // B)
    l += [Z]
print(max(l))

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 >= 1000000:
    for i in range(N-1000000,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:
import math
A,B,N = map(int,input().split())
    
ancer =  math.floor(A*N/B) - A * math.floor(N/ B)

print(ancer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def main():
    inputs = input().split(' ')
    a = int(inputs[0])
    b = int(inputs[1])
    n = int(inputs[2])

    num_list = [x for x in range(1, n+1) if a*x % b == 1]

    ans = 0
    if a > b and b > n:
        pre_ans = math.floor(a*n/b) - a * math.floor(n/b)
        if ans < pre_ans:
            ans = pre_ans

    for x in num_list:
        pre_ans = math.floor(a*x/b) - a * math.floor(x/b)
        if ans < pre_ans:
            ans = pre_ans
        else:
            pass

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

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


max_ = 0
pred = 0
for i in range(b+1):
    ans_ = int(a*i/b) - a*int(i/b)
    if max_ <= ans_:
        max_ = ans_
    if ans_ < pred:
        print(pred)
        sys.exit()
    pred = ans_
print(max_)

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

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

high = N
low = 0
while high - low > 1:
    mid_left = high / 3 + low * 2 / 3
    mid_right = high * 2 / 3 + low / 3
    # print(mid_left, mid_right)
    if f(mid_left) >= f(mid_right):
        high = mid_right
    else:
        low = mid_left
print(f(high))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

# 入力を取得
(a, b, n) = list(map(int, input().split(' ')))

# 計算結果を貯めるlist

# 最大値格納
max = 0

for i in range(1, n + 1):
  ret = get_calc(a, b, i)
  if (ret > max):
    max = ret
  
print(ret)

Submission status: Wrong Answer

Solution code:
import math

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

if (a - 1) * b <= a * n:
    print(a - 1)
    exit()

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

print(ans)

Submission status: Wrong Answer

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

ans = [0]
for x in range(1, 100):
    ad = int((A*x)/B) - (A*int(x/B))
    ans.append(ad)
    
print(max(ans))

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

    if N / B < 1:
        x = N
        res = math.floor(A * x / B)
        return print(res)

    x = (N // B) * B - 1
    res = math.floor(A * x / B) - A * math.floor(x / B)
    print(max(0, res))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = (((a*n)//b)*b+a-1)//a
def calc(x):
    return int(a*x/b)-a*int(x/b)
ans = 0
for i in range(max(0, x-10**5), min(x+10**5, n+1)):
    if ans<calc(i):
        ans = calc(i)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
li=[]
c=math.floor(a*n//b) - math.floor(n//b*a)
li.append(c)
print(min(li))

Submission status: Wrong Answer

Solution code:
# ABC165c
last = 0


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

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

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

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

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

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

        return [lowest, highest]

    t = binary_search(0, n + 1)
    #print(t, last)
    print(last)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    a, b, n = map(int, input().split())
    ans = int((a*n)/b) - a*int(n/b)
    
    if ans <= 0:
        for x in range(n-1, -1, -1):
            val = int((a*x)/b) - a*int(x/b)
            if val > ans:
                ans = val
    
    print(ans)

solve()

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))
    num = max([(a*x)//b - (a*(x//b)) for x in range(b,n+1)])
    if(ma < num):
        ma = num

print(ma)

Submission status: Wrong Answer

Solution code:
import math

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

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

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
num = input()
num = num.split(' ')

A = int(num[0])
B = int(num[1])
N = int(num[2])

import math

anslist = []
for x in range(N):
  ans = math.floor(A*x/B) - A * math.floor(x/B)
  anslist.append(ans)
  
print(max(anslist))

Submission status: Wrong Answer

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

def solve(A: int, B: int, N: int):
    print(math.floor(A*min(B, N)/B) - A * math.floor(min(B, N)/B))
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
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)
b = math.floor(A * N / B) - A * math.floor(N / B)
if a > b:
    print(a)
else:
    print(b)

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 = int((A*N)/B)-A*int(N/B)
if N > 10000000:
    p = N-10000000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

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

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

# print(bisearch(calc, ok, ng))
ans = []
tmp = calc(1)
for i in range(1, min(N+1, 10**6)):
    a = calc(i)
    ans.append(a)
    if tmp > a:
        break
    tmp = a

print(max(ans))

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
if(N<=B):
    x = N
else:
    x =B-1    

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
def floor(x):
  return (x//1)
list = []
X = B
if N >= B:
  while X <= N:
    list.append(floor((A*X)/B)-(A*floor(X/B)))
    X += B
else:
  for x in range(N+1):
    list.append(floor((A*x)/B)-(A*floor(x/B)))
print(int(max(list)))

Submission status: Wrong Answer

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

for i in reversed(range(1, N+1)):
    X = ((A*i) // B)
    Y = A * (i // B)
    if biggest < (X - Y):
        biggest = X - Y
    else:
        break

print(biggest)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))
kouho =[]
A,B,N =line[0],line[1],line[2]
ans = (N+1)//B
for i in range(1,ans+1):
    x= i*B-1
    kouho.append(math.floor(A*x/B)-A*math.floor(x/B))

kouho.append(math.floor(A*N/B)-A*math.floor(N/B))
print(min(kouho))

Submission status: Wrong Answer

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
for i in range(B-1,B):
  print(int(A*i/B)-A*int(i/B))
  #list_ans.append(int(A*i/B)-A*int(i/B))
#print(list_ans)
#print(int(max(list_ans)))

Submission status: Wrong Answer

Solution code:
import math


a, b, n = map(int, input().split())
li = []
x = n
while x > 0:
    an = math.floor(a*x/b) - a * math.floor(x/b)
    li.append(an)
    x -= 1
    if an <= max(li):
        print(max(li))
        exit()

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
if b>10**6:
	print(a*n//b-a*n//b)

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect

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

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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)
b = math.floor(A * N / B) - A * math.floor(N / B)
if a > b:
    print(b)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
import math


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


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

left = -1
right = N

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


print(target(right))

Submission status: Wrong Answer

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

a,b,n=map(int,input().split())
if n<100000000:
    m=0
    for i in range(1,n+1):
        tmp=floor(a*i/b)-(floor(i/b)*a)
        if tmp>m:
            m=tmp
    print(m)
else:
    m=0
    for i in range(n-n//10000000,n+1):
        tmp=floor(a*i/b)-(floor(i/b)*a)
        if tmp>m:
            m=tmp
    print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
abn = list(map(int, input().split()))
a = abn[0]
b = abn[1]
n = abn[2]
ans = 0
for x in range(n + 1):
  val = math.floor(a * x / b) - a * math.floor(x / b)
  if val > ans:
    ans = val
print(val)

Submission status: Wrong Answer

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

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 = N + 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())

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int,input().split())
ans = 0
m = math.floor(n-1000000)
if m < 0:
    for i in range(0,n+1):
        s = math.floor(a * i / b)
        t = math.floor (i/b)
        ans = max(ans,s - a*t) 
else:
    for i in range(m,n+1):
        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:
inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
n = int(inp[2])

y = - 10 ** 10
z = int(a*n/b) - a*int(n/b)
if y < z:
    y = z
s = n//b * b -1
z = int(a*s/b) - a*int(s/b)
if y < z:
    y = z
print(y)

Submission status: Wrong Answer

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

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 = int((A*N)/B)-A*int(N/B)
if N > 100000:
    p = N-100000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(ans)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
if(A*math.floor(N/B)!=0):
    print(A*math.floor(N/B)-1)
else:
    print(math.floor(A*N/B))

Submission status: Wrong Answer

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

import sys
import pprint
import math

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	a, b, n = map(int, sys.stdin.readline().split())
	print(int((n/b - n//b)*a))
	


main()

Submission status: Wrong Answer

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

max=0
for x in range(N+1,int(N*0.9),-1):
  y=(A*x)//B-A*(x//B)
  #print(y)
  if max<y:
    max=y
    #print(x,math.floor(A*x/B),A*math.floor(x/B),y)
print(max)

Submission status: Wrong Answer

Solution code:
import math

def solve(a, b, n):
    ans_arr = []
    for i in reversed(range(1, n + 1)):
        value = math.floor(a * i / b) - a * math.floor(i / b)
        if value == 0:
            next
        else:
            return value

if __name__ == "__main__":
    a, b, n = map(int, input().split(' '))
    print(solve(a,b,n))

Submission status: Wrong Answer

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

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

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


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def naive(a, b, n):
	ans = 0
	for i in range(1, n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

def main(a, b, n):
		return max(val(a, b, n), val(a, b, max((n // b) * b - 1, 1)), val(a, b, max(n - 1, 0)))

# n = 100
# for a in range(1, 100):
# 	for b in range(1, 1000):
# 		if naive(a, b, n) != main(a, b, n):
# 			print(a, b, naive(a, b, n), main(a, b, n))

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

Submission status: Wrong Answer

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

#for i in range(N%B, N+1):
#    ans = max(ans, (math.floor(A*i/B) - A*math.floor(i/B)))

ans = max(ans, (math.floor(A*N/B) - A*math.floor(N/B)))
print(ans)

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
if b>10**6:
	print(a*n//b-a*n//b)

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

Submission status: Wrong Answer

Solution code:
A,B,N = (int(i) for i in input().split())
l = []
for i in range(N):
    x = N
    c = int((A*x)/B)
    d = A * int(x/B)
    e = c - d
    l.append(e)
    if l[i-1] > e:
        print(l[i-1])
        break
    else:
        N -= 1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

c = 0
ans = 0

if N < 1000001:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
else:
  count = B-1
  while N > count:
    c = int(A*count/B) - A*int(count/B)
    if ans < c:
      ans = c
    count += B
    
print(int(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()

if aa < 10**4:
    res = 0
    for x in range(1, N):
        val1 = int((A*x)/B)
        val2 = A*int(N/B)
        cres = val1 - val2
        if res < cres:
            res = cres
    print(res)
    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:
a,b,N=map(int,input().split())
i=0
while(True):
    d=((a*i)//b)-(a*(i//b))
    i=i+1
    if(i>N and i!=N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break
    if(i>N and i==N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# A, B, N = 11, 10, 9

maxR = -1
maxX = 0
for x in range(0, N+1):
    R = math.floor(A*x/B) - A * math.floor(x/B)
    if R >= maxR:
        maxR = R
        maxX = x
print (maxX)

Submission status: Wrong Answer

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

x = 0
x_per_b = 0
d = 1 / b
for x in range( n + 1 ):
    f_x = int( a * x_per_b ) - a * int( x_per_b )
    if x == 0 or f_max < f_x:
        f_max = f_x
    x_per_b = x_per_b + d

print( f_max )

Submission status: Wrong Answer

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

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 = int((A*N)/B)-A*int(N/B)
if N > 1000:
    p = N-1000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_num = -1
max_ans = -1
for x in range(n+1):
  tmp = ((x / b) - (x // b)) * a
  print(tmp)
  if max_num < tmp:
    max_num = tmp
    max_ans = a * x / b // 1 - a * (x / b // 1)
  else:
    break
    
print(int(max_ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = 0

for i in range(N):
    _n = int(A*i/B) - A*int(i/B)
    if n < _n:
        n = _n
    if _n < n-100:
        break

print(n)

Submission status: Wrong Answer

Solution code:

def main():
    A, B, N = map(int, input().split())
    max = ((A*N)//B) - (A * (N//B))

    if B>=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max < temp:
            max = temp
    
    NN = N - A -1
    if NN < 0:
        NN = 0
    for index in (NN,N):
        temp = ((A*index)//B) - (A * (index//B))
        if max < temp:
            max = temp


    print(max)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if n >= b:
    x = int(n/b)*b - 1
else:
    x = n

print(int(a*x/b) - a*int(x/b))

Submission status: Wrong Answer

Solution code:
def calc(x):
    global a, b, n
    return int((a*x) / b) - a * int(x / b)
a, b, n = map(int, input().split())

l = 0
r = min(b, n)
while r - l > 1:
    x = (r + l) // 2
    if calc(x) < n:
        l = x
    else:
        r = x
if calc(l) <= n < calc(r) or calc(r) < calc(l) <= n:
    print(calc(l))
else:
    print(calc(r))

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 >= 100000:
    for i in range(N-100000,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:
a,b,n = map(int,input().split())

max_s = []
j = 0
for i in range(n,0,-1):
    j += 1
    if j == 10**6:
        break
    else:
        num = int((a*i)/b) - a*int(i/b)
        max_s.append(num)
print(max(max_s))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
flag = True
while flag:
  if n < b:
    print(int((n/b - int(n/b))*a))
    flag = False
  elif (n+1)%b == 0:
    print(n,int((n/b - int(n/b))*a))
    flag = False
  n -= 1