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
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])
N = int(tmp[2])
Mmax = 0

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

print(int(ANS))

Submission status: Wrong Answer

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



i = N
wh = -0.00001
while(wh<0):
    ans = int(A*i/B)-A*int(i/B)
    #print(i,ans,ans_before)
    wh = ans_before - ans
    if(ans_before<ans):
      ans_before = ans
    i = i - 1

print(ans_before)

Submission status: Wrong Answer

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

L = []

if N <= B:
  r = N/B
  L.append(int(A*r)-A*int(r))
else:
  for i in range(A):
  	r = (N-i+1)/B
  	L.append(int(A*r)-A*int(r))

print(max(L))

Submission status: Wrong Answer

Solution code:
import math

# 入力
a, b, n = (int(each) for each in 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())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y

if b > n:
    ans = func(1)
    i = 1
    while True:
        i += 1
        if i > n:
            print(ans)
            break
        elif ans > func(i):
            print(ans)
            break
        elif ans <= func(i):
            ans = func(i)
else:
    print(func(b*((n//b)-1)+b-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
max = 0
temp = 0
bk_temp = 0

for i in range(1, N + 1):
    temp = math.floor(A*i/B) - (A * math.floor(i/B))
    print(str(i) + ' ' + str(temp))
    if bk_temp > temp:
        max = bk_temp
        break
    if max < temp:
        max = temp
    bk_temp = temp

print(max)

Submission status: Wrong Answer

Solution code:
A,B, N = map(int,input().split())
B1 =  B
c = 0
while B < N-B:
    B1 = B1 + B
    c += 1
from fractions import Fraction
if c == 0:
    s = int(A*(Fraction(N,B)))
else:
    s = int(A*(Fraction(N-B1,B)))
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math
num = list(map(int, input().split()))
result = math.floor(num[0] * num[2] / num[1]) - num[0] * math.floor(num[2]/ num[1])
print(result)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
#lst=[]
x=0
for i in range(0,n+1,2):
  """
  lst.append(int(a*i/b)-a*int(i/b))
  """
  y=int(a*i/b)-a*int(i/b)
  if y>=x:
    x=y
    
print(x)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
def func(i, j, k):
    return (i*k)//j - i*(k//j)
v = n
for i in range(1, max(b+1, n+1)):
    if (n*a)//b > ((n-1)*a)//b:
        break
    else:
        v -= 1    
print(func(a, b, v))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
C = 0
for i in range(N):
    D = int(A*N/B)-A*int(N/B)
    if D > C:
        C = D
print(C)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if n < b:
    print((a*n)//b)
else:
    ans = -1
    for x in range(b//a, n//b):
        tmp = (a*x)//b - a*(x//b)
        if tmp > ans:
            ans = tmp
        elif tmp < ans:
            break
    print(ans)

Submission status: Wrong Answer

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

lo = 1
hi = N

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

ans = 0
if B-1<=N:
    ans = f(B-1)

while hi > lo :
    if f(lo) <= f(hi):
        mid = (lo + hi) // 2
        if f(mid)<=f(mid+1):
            lo = mid+1
        else:
            lo = mid
    else:
        mid = -(-(lo + hi) // 2)
        hi = mid

ans = max(ans,f(lo),f(N-1),f(B*N//B-1))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

if a == 1:
    print(0)
elif a==b:
    print(func(n+1))
elif a>b:
    print(func(n))
else:
    flag = False
    ans = 0
    for i in range(n):
        tmp = func(i)
        if flag and tmp ==0:
            break
        elif flag:
            ans = tmp
        elif not flag and tmp != 0:
            ans = tmp
            flag = True
    print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

v = N % B
v += 1
bbb = 0
if N - v >= 1:
    bbb = math.floor(A * (N - v) / B) - A * math.floor((N - v)/ B)

print(max(aaa, bbb))

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

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

if N < B:
    ans = math.floor((A * N) / B) - A * math.floor(N / B)
    print(ans)
else:
    if B == 1:
        underB = 0
    else:
        underB = math.floor((A * (B - 1)) / B)
    eqB = 0
    eqN = math.floor((A * N) / B) - A * math.floor(N / B)
    print(max(underB, eqB, eqN))

Submission status: Wrong Answer

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

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

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

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

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

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

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math
 
A, B, N = map(int, input().split())
c = 0
for x in range(0, N+1):
    j = (A*x / B)
    k = (x / B)
    if j < 1:
        pass
    else:
        a = math.floor(j) - A * math.floor(k)
        print(x, a)
        if a > c:
            c = a
print(c)

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a, b, n = map(int, input().split())
    l = 0
    r = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
    while(l+1 < r):
        x = (l+r)//2
        print(x)
        t = math.floor(a*x/b) - a*math.floor(x/b)
        if ans <= t:
            ans = t
            r = x
        else:
            l = x

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
import math
x=b-1
m=[0]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

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 == 344000000:
    break

print(mx)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def f(n):
    d = int(A*n/B) - A*int(n/B)
    return d

print(f(N))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

for i in range(N):
    n = (N - i)
    f = int((A*n)/B) - A*int(n/B)
    if f >= ans:
        ans = f
    else:
        break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

m = math.floor(a*n/b)
c = 0
if n>=b:
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        #print('b:',c)
        if c >= m:
            m=c
        else:
            break
print(m)

Submission status: Wrong Answer

Solution code:
import math


a,b,n = map(int,input().split())
max=0
ans=0
n_2=int(n/2)
for i in range(n_2,n+1):
    ans=math.floor(i*a/b)-a*math.floor(i/b)
    print(max)
    if max<ans:
        max=ans

print(max)

Submission status: Wrong Answer

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

ans = 0
i = 1
while True:
    i += max(1, B//A)
    if i > N:
        break
    tmp = ((A*i)//B) - (A*(i//B))
    if tmp >= ans:
        ans = tmp
    else:
        break
        
print(ans)

Submission status: Wrong Answer

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

    # import random

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

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

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=floor(a*n/b)-a*floor(n/b)
x=n//b*b-1
if x<0:
    x=n-1
cand2=floor(a*x/b)-a*floor(x/b)
cand1=max(cand2,cand1)

for i in range(1000001):
    n-=1
    if n>=0:
        cand2=floor(a*n/b)-a*floor(n/b)
        cand1=max(cand1,cand2)
    else:
        break
print(cand1)

Submission status: Wrong Answer

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

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

ans = 0
for i in range(1,min(a+1,n+1)):
  ans = max(ans,f(i))
    
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    max = 0
    a, b, n = map(int, input().split())
    if n < b:
        max = int(a*n/b)
    else:
        for i in range(1, n+1, b):
            ans = int(a*i/b) - a*int(i/b)
            if max < ans:
                max = ans

    return max

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

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 = 0
    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 = query_value(a, b, left)
    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
A, B, N = map(int, input().split())

ans = 0

if N // B == 0:
  x = N % B
else:
  x = B * (N // B) -1

a = math.floor((A * x) / B) - A * math.floor(x / B)


print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 1
buf = []
while True:
    x = cnt * b - 1
    if a < x:
        break
    calc = int(a * x / b) - a * (int(x / b))
    buf.append(calc)
    cnt += 1
    
buf.append(int(a * n / b) - a * (int(n / b)))

ans = max(buf)
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
kind=set()
for i in range(1,n+1):
    num=calc(i)
    if num in kind:
        break
    kind.add(num)
print(max(kind))

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:
A, B, N = map(int, input().split())
from math import floor
from math import gcd

k = gcd(A, B)

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

if B < 100:
    res = []
    for n in range(min(N+1, B+1)):
        res.append(round(floor(As*n/Bs)-As*floor(n/Bs)))

    print(max(res))
    exit()

if Bs-1 <= N:
    m = Bs - 1
else:
    m = N
print(round(floor(As * m / Bs) - As * floor(m / Bs)))
# for x in range(1, N+1):
#     print(floor(As*x/Bs)-As*floor(x/Bs))

Submission status: Wrong Answer

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

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

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

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

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

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

# main()
print(main())

Submission status: Wrong Answer

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

ans = int(A*N/B) - A*int(N/B)

print(ans)

Submission status: Wrong Answer

Solution code:

A,B,N = map(int, input().split())
ans = [0]
for t in range(N):
    x = t +1
    ansX = A*x//B-A*(x//B)
    if ansX == max(ans):
        break
    else:
        ans.append(ansX)
print(max(ans))

Submission status: Wrong Answer

Solution code:
a, b,n = list(map(int, input().split()))
res = 0
for x in range(1, n+1):
    print((a*x)//b, a *(x//b) )
    if  a *(x//b) != 0:
        break
    if res < (a*x)//b - a *(x//b):
        res = (a*x)//b - a *(x//b)

print(res)

Submission status: Wrong Answer

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

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

print(int(ANS))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))

A,B,N =line[0],line[1],line[2]

ans = (N+1)//B
if ans ==0:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    kouho =[0 for j in range(ans)]
    for i in range(1,ans+1):
        x= i*B-1
        kouho[i-1]=(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=map(int,input().split())
d=((a*(n))//b)-(a*((n)//b))
e=((a*(n-1))//b)-(a*((n-1)//b))
f=((a*(b-1))//b)-(a*((b-1)//b))
print(max(d,e,f))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math 

a, b, n = map(int, input().split())
if n < b:
    print(math.floor(a*n/b))
else:
    ls = [math.floor(a*i/b)-(a*math.floor(i/b)) for i in range(b, n+1)]
    print(max(ls))

Submission status: Wrong Answer

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

print(ans)

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

Submission status: Wrong Answer

Solution code:
import math

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


ans1 = 0

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

Submission status: Wrong Answer

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

ans = -1
if(n > 10**6 and a % b == 0):
    for x in range(b-1,n+1,b):
        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))
        print(x ,abc)
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)

ans = function(1)
for i in (1, n):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(ans)

Submission status: Wrong Answer

Solution code:
a, b , n = map(int, input().split())
def floor_abx(a, b, x):
    return int(a*x/b) - int(x/b)*a 
    
res = 0
for i in range(n+1-abs(a-b), n+1):
    num = floor_abx(a, b, i)
    if res < num:
        res = num
print(res)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
saidai = 0
if N <= 10**7:
    S = 0
else:
    S = N - 10**7
    
for x in range(S,N+1):
    f = (A*x)//B - (A * (x//B))
    if f > saidai:
        saidai = f

if N >= 10**10:
    for i in range((B//N)+1):
        x = (B*i)-1
        f = (A*x)//B - (A * (x//B))
        if f > saidai:
            saidai = f

print(saidai)

Submission status: Wrong Answer

Solution code:
import math

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

if b == 1:
    print(0)
    exit()

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def binary_search():
    low = 1
    high = n

    m = 0

    while low <= high:
        mid = (low + high) // 2

        l = int(a*low/b) - a * (int(low/b))
        h = int(a*high/b) - a * (int(high/b))

        if h > l:
            high = mid -1
            m = max(m, l, h)
        else:
            low = mid + 1
            m = max(m, l, h)

    return m


print(binary_search())

Submission status: Wrong Answer

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

ans = 0
for X in range(N):
    fl1 = (A*(X+1))//B
    fl2 = (X+1)//B

    fl = fl1 - A*fl2
    if(fl >= ans):
        ans = fl

print(fl)

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(1,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(1,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 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**5):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for _ in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= learning_rate * 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:
A, B, N = map(int, input().split())
max = 0
li = []
for x in range(1, N+1):
    fun = int(A*x/B) - A*int(x/B)
    if x == 1:
        x0 = fun
    elif x0 == fun:
        break
    if max < fun:
        max = fun
print(max)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
lst=[]
if n>=b:
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    ans3=int(a*(b-1)/b)-a*int((b-1)/b)
    ans4=int(a*(b+1)/b)-a*int((b+1)/b)
    ans5=int(a*(2*b-1)/b)-a*int((2*b-1)/b)
    ans6=int(a*(2*b+1)/b)-a*int((2*b+1)/b)
    p=n//b
    ans7=ans5=int(a*(p*b-1)/b)-a*int((p*b-1)/b)
    print(max(ans,ans2,ans3,ans4,ans5,ans6,ans7))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print(max(ans,0))

Submission status: Wrong Answer

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

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

k = min(B, N)
ans = int(A * k / B) - A * int(k / B)
print(ans)

Submission status: Wrong Answer

Solution code:
import math


def check(A, B, mid):
    return math.floor(A * mid / B) - A * math.floor(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:
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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

a, b, n = [int(x) for x in input().split()]

for x in range(0, n):
    result = floor(a*x)/b - a*floor(x/b)

print(round(result))

Submission status: Wrong Answer

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

ans = 0

for i in range(N):
    n = (N - i)
    f = int((A*n)/B) - A*int(n/B)
    print(f)
    if f >= ans:
        ans = f
    else:
        break 

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans = -float('inf')

import math

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

print(ans)

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(n-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:
import math
a, b, n = map(int,input().split())
ans = 0
m = math.floor(n-10000000)
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)
    for i in range(1, 10000000):
        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:
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,max(0,B*(N//B)-1)))


print(ans)

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

if (n >=b):
  x=int(n/b)*b-1
# print (int(a*x/b)-a*int(x/b))
  print (int(a*(int(n/b)-1./b))-a*int(int(n/b)-1./b))
else:
  xmax=0
  for x in range(1,n+1):
    atai=int(a*x/b)-a*int(x/b)
    if (atai >= xmax): xmax=atai
  print (xmax)