Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
from 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)
ans2 = int((A*(B-1))/B)-A*int((B-1)/B)

    
 
 
print(max(ans, ans2))

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 >= B:
   
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
   
else:

    ans2 = ans
    
 
 
print(max(ans, ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import math
def main():
    A, B, N = map(int, input().split())
    x = min(N, B)
    ans = math.floor(A*x/B) - A * math.floor(x/B)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
import random
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    ans=0
    for i in range(10**6):
        k=random.randint(0,N)
        ans=max(ans,f(A,B,k))
    print(ans)
#%%submit!
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

else:
    m = n//b
    m = m*b-1
    ans = floor(a*m/b)-a*(m//b)
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = a*n//b
else:
    for i in range(b, n):
        res = a*i//b - a*(i//b)
        if ans < res:
            ans = res
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = list(map(int, input().split()))
def function(a, b, x):
  return (a*x)//b - a*(x//b)
print(max([function(A, B, N), function(A, B, N-N%B-1)]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
 
A, B, N = map(int, input().split())
ans = 0
for x in range(1, B):
    tmp = int(A*x/B) - A * int(x/B)
#    print("x:\t" + str(x) + "\ttmp:\t" + str(tmp))
    if (ans<tmp):
        ans = tmp
        y = x
print(ans)

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

Submission status: Wrong Answer

Solution code:
 
A, B, N = map(int, input().split())
ans = 0
for x in range(1, B):
    tmp = int(A*x/B) - A * int(x/B)
    print("x:\t" + str(x) + "\ttmp:\t" + str(tmp))
    if (ans<tmp):
        ans = tmp
        y = x
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = list(map(int, input().split()))
def function(a, b, x):
  return (a*x)//b - a*(x//b)
print(max([function(A, B, i) for i in range(max([1, N-N%B]), N+1)]))

Submission status: Wrong Answer

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

else:
    m = n//b
    m = m*b-1
    ans = floor(a*m/b)-a*floor(m/b)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  a = 0

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

if ans < math.floor((A*N)/B) - A*math.floor(N/B):
  re = math.floor((A*N)/B) - A*math.floor(N/B)
else:
  re = ans
print(re)

Submission status: Wrong Answer

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

i = 1
x = 0
mx = 0
pt = 0

while(x < min(A*B, N)):
    x = (i * B) // A
    pt = (A * x) // B - A * (x // B)
    mx = max(mx, pt)
    i += 1
    
print(mx)

Submission status: Wrong Answer

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

a,b,n = (int(x) for x in input().split())
if b-1<=n:
	ans = a-1
else:
	ans = (a*n/b) - a*(n/b)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
A,B,N=map(int,input().split())
X=B-1
X=max(B-1,N)
ans=(A*X)//B-A*(X//B)
print(ans)

Submission status: Wrong Answer

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

a,b,n = (int(x) for x in input().split())
if b-1 < n:
    ans = a-1
else:
    ans = (a*n/b) - a*(n/b)
print(ans)

Submission status: Wrong Answer

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

a,b,n = (int(x) for x in input().split())
if b < n:
    ans = a-1
else:
    ans = (a*n/b) - a*(n/b)
print(ans)

Submission status: Wrong Answer

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

a,b,n = (int(x) for x in input().split())
if b <= n:
    ans = a-1
else:
    ans = (a*n/b) - a*(n/b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
res = f(a, b, n)
i = n - 1
cont = 0
while i > 0 and cont < 10000000:
    if f(a, b, i) > res:
        res = f(a, b, i)
        cont = 0
    else:
        cont += 1
    i -= 1
print(res)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
res = f(a, b, n)
i = n - 1
cont = 0
while i > 0 and cont < 100000:
    if f(a, b, i) > res:
        res = f(a, b, i)
        cont = 0
    else:
        cont += 1
    i -= 1
print(res)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
res = f(a, b, n)
i = n - 1
cont = 0
while i > 0 and cont < 1000:
    if f(a, b, i) > res:
        res = f(a, b, i)
        cont = 0
    else:
        cont += 1
    i -= 1
print(res)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
res = f(a, b, n)
i = n - 1
cont = 0
while i > 0 and cont < 500:
    if f(a, b, i) > res:
        res = f(a, b, i)
        cont = 0
    else:
        cont += 1
    i -= 1
print(res)

Submission status: Wrong Answer

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

i = 1
x = 0
mx = 0
pt = 0

while(x < N):
    x = (i * B) // A
    pt = (A * x) // B - A * (x // B)
    mx = max(mx, pt)
    i += 1
    
print(mx)

Submission status: Wrong Answer

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

a,b,n = (int(x) for x in input().split())
if b <= n:
    ans = a-1
else:
    ans = int(float(n) / (float(b)/a))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def f(a, b, i):
    return math.floor((a * i) / b) - a * math.floor(i / b)
a, b, n = map(int, input().split())
i = 0
while i < n:
    i += 1
print(f(a, b, i))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  a = 0
ans = math.floor(A*a/B) - A*math.floor(a/B)

if ans < math.floor(A*N/B) - A*math.floor(N/B):
  re = math.floor(A*N/B) - A*math.floor(N/B)
else:
  re = ans
print(re)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  a = 0
  ans = math.floor(A*a/B) - A*math.floor(a/B)
else:
  ans = math.floor(A*a/B) - A*math.floor(a/B)
  
if ans < math.floor(A*N/B)-A*math.floor(N/B):
  re = math.floor(A*N/B)-A*math.floor(N/B)
else:
  re = ans
print(re)

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=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

# def f_diff(f, x, h=B):
#     return f(x + h) - f(x)

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

    # 所定の回数を繰り返す

    p_grad = 0
    for step in range(steps):
        grad = numerical_diff(f, x) + 0.9 * p_grad
        p_grad = grad
        x -= learning_rate * grad
        if x < 0:
            x = 0
        elif x > N:
            x = N

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

ma = 0
for _ in range(100):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  ans = math.floor(A*0/B) - A*math.floor(0/B)
else:
  ans = math.floor(A*a/B) - A*math.floor(a/B)
if ans > math.floor(A*N/B)-A*math.floor(N/B):
  re = ans
else:
  re = math.floor(A*N/B)-A*math.floor(N/B)
print(re)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import math

A, B, N = map(int, input().split(' '))
x = B
print(math.floor((A * x) / B) - A * (math.floor(x / B)))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  ans = math.floor(A*0/B) - A*math.floor(0/B)
else:
  ans = math.floor(A*a/B) - A*math.floor(a/B)
if ans > math.floor(A*N/B)-A*math.floor(a/B):
  re = ans
else:
  re = math.floor(A*N/B)-A*math.floor(a/B)
print(re)

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) - A * (math.floor(x / B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a <= 0:
  ans = math.floor(A*(N%B)/B) - A*math.floor((N%B)/B)
else:
  ans = math.floor(A*a/B) - A*math.floor(a/B)
print(ans)

Submission status: Wrong Answer

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

result = []
for _ in range(n):
    result_a = math.floor(a*int(n/2)/b) - a*math.floor(int(n/2)/b)
    result_b = math.floor(a*int(n/2+1)/b) - a*math.floor(int(n/2+1)/b)
    if result_a < result_b:
        result.append(result_b)
        n = int(n*3/2)
    elif result_a > result_b:
        result.append(result_a)
        n = int(n*1/2)
    elif result_a == result_b:
        result.append(result_b)
        
    
print(max(result))

Submission status: Wrong Answer

Solution code:
A, B ,N = map(int,input().split())
x = 0
max = 0
while True:
  result = int((A*x)/B) - (A*int(x/B))
  if result > max:
    max = result
  if x/B >= 1:
    break
  x = x + 1
print(max)

Submission status: Wrong Answer

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

n = min(B-1,N%B)

ans = (A*n)//B
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

n = min(N,N%B)
if n == 0:
    n = N-1
ans = (A*n)//B
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = min(N,N%B)
if n == 0:
    n = B-1
ans = (A*n)//B
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
A, B, N = map(int, input().split())
def calc(num):
    ans = A * num // B - A * num // B
    return ans

print(min(calc(B-1), calc(N)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math
A, B, N = map(int, input().split())
def calc(num):
    ans = math.floor(A * num / B) - A * math.floor(num / B)
    return ans

print(min(calc(B-1), calc(N)))

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
answer = 0

max_first = int(A * N / B)
min_first = int(A * 1 / B)
max_last = int(N / B)
min_last = int(1 / B)
for i in range(min_first, max_first + 1):
  for j in range(min_last, max_last + 1):
    answer = max(i - A * j, answer)

print(answer)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
answer = 0

max_first = int(A * N / B)
min_first = int(A * 1 / B)
max_last = int(N // B)
min_last = int(1 // B)
for i in range(min_first, max_first + 1):
  for j in range(min_last, max_last + 1):
    answer = max(i - A * j, answer)

print(answer)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
answer = 0

max_first = A * N // B
min_first = A * 1 // B
max_last = N // B
min_last = 1 // B
for i in range(min_first, max_first + 1):
  for j in range(min_last, max_last + 1):
    answer = max(i - A * j, answer)

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a==1:
  print(0)
else:
  c = max(b-1, n)
  print((a*c)//b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = min(N,N%B)
ans = (A*n)//B
print(ans)

Submission status: Wrong Answer

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

max_value = 0

for x in range(n):
  f = math.floor(a*x/b)-a*math.floor(x/b)
  if f >= max_value:
    max_value = f
    
print(max_value)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
ans = 0
if N>=B:
    p = B*(N//B)-1
    q =math.floor(A*p/B)-A*int(math.floor(p/B))
else:
    q =0
if N%B!=0:
    ans=math.floor(A*N/B)-A*int(math.floor(N/B))
else:
    ans=math.floor(A*(N-1)/B)-A*int(math.floor((N-1)/B))
print(max(q,int(ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

m = min(b,n)
print(max(list(map(lambda y: keisan(a, b, y) ,range(0,m)))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math
ans = []
for x  in range(n+1):
    l = math.floor(a*x/b)
    r = a*math.floor(x/b)
    ans.append(l-r)
    if l-r == ans[0] and len(ans) > 100:
        break
        
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = (int(x) for x in input().split())
from math import floor
ans = 0
for x in range(1, n+1):
    s = floor((a*x)/b)
    if ans < s:
        ans = s
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math
ans = []
for x  in range(n+1):
    l = math.floor(a*x/b)
    r = a*math.floor(x/b)
    ans.append(l-r)
    if l-r == ans[0] and x != 0:
        break
        
print(max(ans))

Submission status: Wrong Answer

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


if n//b < 1:
    print((a*n)//b)
else:
    print(max((a*n)//b,a-((a-1)//b+1)))

Submission status: Wrong Answer

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


if n//b < 1:
    print((a*n)//b)
else:
    print(max((a*n)//b,(a*b-a)//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

if (N>=2*B-1):
    n=B-1
elif (B<N<2*B-1):
    n=max(N-B,B-1)
else:
    n=N

print(int(A*n/B))

Submission status: Wrong Answer

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

#for x in range(1,N+1):
#    S=int(A*x/B)-A*int(x/B)

S=int(A*N/B)-A*int(N/B)
print(S)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
S =[]
 
for x in range(0,N):
  c = int(A*x/B)
  d = int(x/B)
  d = d * A
  E = c-d
  S.append(E)
  
print(max(S))

Submission status: Wrong Answer

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

if b == 1 or a == 1:
    print(0)
    exit()
if n//b < 1:
    print((a*n)//b)
else:
    print(max((a*n)//b,a-a//b))

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=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

def f_diff(f, x, h=B):
    return f(x + h) - f(x)

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

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

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

ma = 0
for _ in range(10 ** 2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

max=-100000000000000

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

Submission status: Wrong Answer

Solution code:
def main():
	a,b,n = map(int,input().split())
	
	x = n
	while x > 0:
		x -= 1
		if (int((a*x)/b) - (a* int(x/b))) == 0 and (int( (a*(x-1)) /b) - (a* int((x-1)/b))) != 0:
			print( int( (a*(x-1)) /b) - (a* int((x-1)/b)) )
			break

if __name__ == '__main__':
	main()

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=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

def f_diff(f, x, h=B):
    return (f(x + h) - f(x)) / h

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

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

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

ma = 0
for _ in range(10 ** 2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

Solution code:
def main():
	a,b,n = map(int,input().split())
	
	x = n
	while x > 0:
		x -= 1
		print(x)
		if (int((a*x)/b) - (a* int(x/b))) == 0 and (int( (a*(x-1)) /b) - (a* int((x-1)/b))) != 0:
			print( int( (a*(x-1)) /b) - (a* int((x-1)/b)) )
			break

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
INT_MAX=10**19+7
MOD=10**12+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
a,b,n=INPUT()
if n<=b:
    print(int(a*n/b))
else:
    print(int(a*(b-1)/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


print(ans)

Submission status: Wrong Answer

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

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=B):
    """中央差分を元に数値微分する関数"""
    return (f(x + h) - f(x - h)) / (2 * h)

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

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

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

ma = 0
for _ in range(10 ** 2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

Solution code:
import sys

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

if (N>=2*B-1):
    n=B-1
elif (B<N<2*B-1):
    n=N-B
else:
    n=N

print(int(A*n/B))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  ans = math.floor(A*N/B) - A*math.floor(N/B)
else:
  if N%B >= a or N%B == 0:
    ans = math.floor(A*a/B) - A*math.floor(a/B)
  else:
    ans = math.floor(A*(N%B)/B) - A*math.floor((N%B)/B)
print(ans)

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(x) for x in input().split())
a = (N//B)*B-1
if a < 0:
  ans = math.floor(A*N/B) - A*math.floor(N/B)
else:
  if N%B >= a:
    ans = math.floor(A*a/B) - A*math.floor(a/B)
  else:
    ans = math.floor(A*(N%B)/B) - A*math.floor((N%B)/B)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

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

max=-10000000
x_max=-1

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

Submission status: Wrong Answer

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

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

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

print(max(res))

Submission status: Wrong Answer

Solution code:
import math

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

max=-10000000
x_max=-1

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

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


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