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 = map(int,input().split())
c = n // b * b
ans=0
if n > b - 1:
    ans = math.floor(a * c / b) - a * math.floor(c / b)

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

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

print(ans)

Submission status: Wrong Answer

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

ans=0
if n > b - 1:
    for i in range(b-1,n,b):
        if math.floor(a * (i+1) / b) - a * math.floor((i+1) / b) > ans:
            ans = math.floor(a * (i+1) / b) - a * math.floor((i+1) / b)

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

print(ans)

Submission status: Wrong Answer

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

n_min = int((a-1)*b/a) + 1
ans = 0

if n == b:
    print(0)
    quit()


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

else:
    ans = a - 1
    print(ans)

Submission status: Wrong Answer

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

n_min = int((a-1)*b/a) + 1
ans = 0


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

else:
    ans = a - 1
    print(ans)

Submission status: Wrong Answer

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

n_min = int((a-1)*b/a) + 1
ans = 0


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

else:
    for i in range(n_min, b):
        ans = max(ans, ((a * i) // b - a * (i // b)))

    print(ans)

Submission status: Wrong Answer

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

n_min = int((a-1)*b/a) + 1
ans = 0


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

else:
    for i in range(n_min, b):
        ans = max(ans, (int(a * i / b) - a * int(i / b)))

    print(ans)

Submission status: Wrong Answer

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

n_min = int((a-1)/(a*b)) + 1
ans = 0


if n < b-1:
    for i in range(n_min, n):
        ans = max(ans, (int(a * i / b) - a * int(i / b)))

    print(ans)

else:
    for i in range(n_min, b):
        ans = max(ans, (int(a * i / b) - a * int(i / b)))

    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if n > b:
    print(a-1)
elif n == b:
    m = n - 1
    print(math.floor(a*m/b)-a*math.floor(m/b))
else:
    print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
import math

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

if n > b:
    print(a-1)
elif n == b:
    m = n - 1
    print(math.floor(a*m/b)-a*math.floor(m/b)+1)
else:
    print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
T=[]
for i in range(max(1,N+1-B),N+1):
  t = math.floor(A*i/B)-A*math.floor(i/B)
  T.append(t)
print(max(T))

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
T=[]
for i in range(max(1,N-100),N+1):
  t = math.floor(A*i/B)-A*math.floor(i/B)
  T.append(t)
print(T)
print(max(T))

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
T=[]
for i in range(max(0,N-100),N):
  t = math.floor(A*i/B)-math.floor(i/B)
  T.append(t)
print(max(T))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
c_0 = 0
m = min(n, b) + 1
for x in range(1, m):
  c = int(a * x / b)
  if c > c_0:
    c_0 = c
print(c_0)

Submission status: Wrong Answer

Solution code:
def solve(a, b, n):
    return (a*n//b - n//b) if a > 1 else 0
assert solve(5, 7, 4) == 2
assert solve(11, 10, 9) == 9

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

Submission status: Wrong Answer

Solution code:
import math

a, b, n = [int(x) for x in input().split()]
# a = 10 ** 6
# b = 10 ** 12
# n = 10 ** 12

m = 0
if (n < b):
    m = math.floor(a * n / b) - a * math.floor(n / b)
else:
    for i in range(n // b - 1, n + 1, b):
        #print(math.floor(a * i / b),  a * math.floor(i / b))
        m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
if (n < b):
    m = math.floor(a * n / b) - a * math.floor(n / b)
else:
    for i in range(min(a, b), n + 1, n // b):
        m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
for i in range(min(a, b, n), n + 1):
    print(math.floor(a * i / b), a * math.floor(i / b))
    m = max(m, math.floor(a * i / b) - a * math.floor(i / b))

print(m)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    # k, r = divmod(N, B)
    if B - 1 < N:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))

    # maxM = calcM(A, B, min(N, B - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    # k, r = divmod(N, B)
    if B - 1 <= N:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))

    # maxM = calcM(A, B, min(N, B - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    # k, r = divmod(N, B)
    # if k and B * k -1 <= N:
        # k * B - 1で調査
    maxM = max(maxM, calcM(A, B, B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))

    # maxM = calcM(A, B, min(N, B - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    if k and B * k -1 <= N:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))

    # maxM = calcM(A, B, min(N, B - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    if k and B * k -1 <= N:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, k * B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    # if k:
        # k * B - 1で調査
    maxM = max(maxM, calcM(A, B, k * B - 1))
    # if r == 0:
    #     maxM = max(maxM, calcM(A, B, N - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    if k:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, k * B -1))
    if r == 0:
        maxM = max(maxM, calcM(A, B, N - 1))


    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)

    k, r = divmod(N, B)
    if k:
        # k * B - 1で調査
        maxM = max(maxM, calcM(A, B, k * B -1))

    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    if B < N:
        max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N-B, N+1))), default=N)
        return max(maxM, calcM(A, B, max_x))
    return maxM

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N-B, N+1))), default=N)
    # print('max_x:', max_x)
    return max(maxM, calcM(A, B, max_x))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

Solution code:
# floor(Ax/B) - A floor(x/B) の最大値Mを求める
# xはN以下の非負整数
# floor(Ax / B) = M + A floor(x / B)
# x / B = k + r
# Ax / B = Ak + Ar

# floor(Ak + Ar) = M + A floor(k + r)
# Ak + floor(Ar) = M + Ak + A floor(r)
# floor(Ar) = M

# r = x / B - k
# M = floor(A * (x / B - k))
#   = floor(A * x /B) - Ak
#   = floor(A/B * x) - Ak
#   = floor(A/B * x) - A * (x // B) 

# A B N
# 5 7 4

# M = floor(5/7 * x) - 5 * (x // 7)


# A B N 
# 11 10 9
# M = floor(11 / 10 * x) - 11 * (x // 10)

import math

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

def resolve_v1(A, B, N):
    maxM = 0
    for x in range(N+1): # O(N)
        M = calcM(A, B, x)
        maxM = max(maxM, M)

    return maxM

def resolve_v2(A, B, N):
    # x == kB - 1
    maxM = calcM(A, B, N)

    for x in filter(lambda x: (x + 1) % B == 0, range(N+1)): # O(N/B)
        maxM = max(maxM, calcM(A, B, x))
    return maxM


def resolve_v3(A, B, N):
    maxM = calcM(A, B, N)
    max_x = max(list(filter(lambda x: (x + 1) % B == 0, range(N+1-B, N+1))), default=N)
    # print('max_x:', max_x)
    return max(maxM, calcM(A, B, max_x))

if __name__ == '__main__':
    A, B, N = map(int, input().split())
    M = resolve_v3(A, B, N)
    print(M)

Submission status: Wrong Answer

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

print(min(n,b-1))

Submission status: Wrong Answer

Solution code:
import math

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

a=N//B

if a==0:
    x=N
    

elif N%B==0:
    x=a*B-1
else:
    x=B*a-1

while math.floor(A*x/B)==math.floor(A*(x-1)/B):
    x=x-1
    if x==1:
        break
ans=math.floor(A*x/B)-A*math.floor(x/B)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

a=N//B

if a==0:
    x=N
    

elif N%B==0:
    x=a*B-1
else:
    x=B*a-1

ans1=math.floor(A*x/B)-A*math.floor(x/B)
ans2=math.floor(A*N/B)-A*math.floor(N/B)
ans=max(ans1,ans2)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

a=N//B

if a==0:
    x=N
    

elif N%B==0:
    x=a*B-1
else:
    x=B*(a-1)-1

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

print(ans)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split(" "))
 
max_score = 0
y = b // a
 
for x in range(max(y - 1000000, 1) , min(y + 2000000, n+1)):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Wrong Answer

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

max_score = 0
y = b // a

for x in range(max(y - 10000, 1) , min(y + 20000, n+1)):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Wrong Answer

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

max_score = 0
y = b // a

for x in range(max(y - 100, 1) , min(y + 200, n+1)):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Wrong Answer

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

max_score = 0
y = a // b
for x in range(y - 100, y + 200):
    score = a * x // b - a * ( x // b )
    if score > max_score:
        max_score = score
print(max_score)

Submission status: Wrong Answer

Solution code:
import math
 
a = list(map(int, input().split()))
A = a[0]
B = a[1]
N = a[2]
 
if N%B !=0:
  x_1 = (N//B)*B-1
  if x_1 == -1:
    x_1 = N
  x_2 = N
elif N == 1 or B ==1:
  x_1 =N
  x_2 =N

else:
  x_1 = N-1
  x_2 = N-1
ans_1 = math.floor(A*x_1/B)-A*math.floor(x_1/B)
ans_2 = math.floor(A*x_2/B)-A*math.floor(x_2/B)
if ans_1 >= ans_2:
  print(ans_1)
else:
  print(ans_2)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(x) for x in input().split()]
def func(A, B, x):
    return int(A * x/ B) - A * int(x/B)

if B < N:
    print(func(A, B, B - 1))
else:
    print(func(A, B, N))

Submission status: Wrong Answer

Solution code:
A, B, N = [int(x) for x in input().split()]
def func(A, B, x):
    return int(A * x/ B) - A * int(x/B)

print(func(A, B, N))

Submission status: Wrong Answer

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

def floor(x):
    out = (A * x)//B - A * (x//B)
    return out

max = 0
#for i in range(N//2, N + 1):
    #if(floor(i) > max):
        #max = floor(i)

if(floor(N) >= floor(B-1)):
    max = floor(N)
else:
    max = floor(B-1)

print(max)

Submission status: Wrong Answer

Solution code:
import math
import sys

a, b, c = map(int, sys.stdin.readline().rstrip().split())
tmp = []
for ai in range(a):
    tmp.append(math.floor((a * ai) / b) - a * math.floor(ai / b))
# print(tmp)
print(max(tmp))

Submission status: Wrong Answer

Solution code:
from math import floor
def Main(A, B, N):
    a = floor(A*N/B)-A*floor(N/B)
    b = floor(A*(B-1)/B)-A*floor((B-1)/B)
    return max(a, b)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import floor
def Main(A, B, N):
    return floor(A*(N)/B)-A*floor((N)/B)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#ABC165d
import math

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

Submission status: Wrong Answer

Solution code:
import math

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

if B == 1:
    print(0)
else:
    print(min(math.floor(A*N/B), A-1))

Submission status: Wrong Answer

Solution code:
#ABC165d
a, b, n = map(int,input().split())
M = 0
Ma = 0
for i in range(n):
    M = float(int(float(a*i)/float(b)))-float(float(a)*int(float(i)/float(b)))

    if M > Ma:
        Ma = M
print(int(Ma))

Submission status: Wrong Answer

Solution code:
import math

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

print(math.floor(a*x/b))

Submission status: Wrong Answer

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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))
x=(B * (W+1))-1
dammy.append((A*x)//B - A * int(x/B))

print(max(dammy))

Submission status: Wrong Answer

Solution code:
import math

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

A, B, N = map(int, input().split(' '))
x = min(N, B-1)
print(min(floor(A,B,N), floor(A,B,B-1)))

Submission status: Wrong Answer

Solution code:
import math

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

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

print(max(floor(A,B,N), floor(A,B,B-1)))

Submission status: Wrong Answer

Solution code:

import math

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


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

print(ans)

Submission status: Wrong Answer

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

x = max(b,n-1)
ans = a*x//b - a*(x//b)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
import math

input1 = input().split()
A = int(input1[0])
B = int(input1[1])
N = int(input1[2])

x = 0
result = 0
if N >= B-1:
    x = B-1
    result = (A*(x%B) - (A*x)%B)/B
elif N < B-1:
    x = N
    result = (A*(x%B) - (A*x)%B)/B

print(result)

Submission status: Wrong Answer

Solution code:
import math

input1 = input().split()
A = int(input1[0])
B = int(input1[1])
N = int(input1[2])

result = 0
if N >= B-1:
    result = B-1
elif N < B-1:
    result = N

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


if n < b:
    print(f(n))
else:
    print(f(b))

Submission status: Wrong Answer

Solution code:
import math
def equation(a,b,n):
  return math.floor((a*n)/b)-a*math.floor(n/b)
d,e,f = map(int,input().split())
X = equation(d,e,f)
Y = equation(d,e,e-1)
print(min(X,Y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N <B:
	print(math.floor(A*N/B))
	exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b-1:
    print(math.floor(a*n/b))
#    exit()
else:
    print(math.floor(a*(b-1)/b)-a*math.floor(b-1/b))

Submission status: Wrong Answer

Solution code:
import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
#if n<=b:
print(math.floor(a*n/b))
#    exit()

Submission status: Wrong Answer

Solution code:
import math
 
a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b:
    print(math.floor(a*n/b))
    exit()

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n%(10**6)):
    #print(a*((x+1)%b)//b)
    if a*((x+1)%b)//b > ans:
        ans = a*((x+1)%b)//b

#print("----------")
print(ans)

Submission status: Wrong Answer

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

A,B,N = map(int,input().split())
print(min(f(B-1), f(N)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B, N = rl()

max_v = 0
for x in range(1, min(200, N)+1):
	v = math.floor(A * x / B) - A * math.floor(x/B)
	if max_v < v:
		max_v = v
print(max_v)