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:
A,B,N=map(int,input().split())
if B<N:
	C=B-1
else:
	C=N
x=int(A*C/B)
y=int(C/B)
z=x-A*y
print(z)

Submission status: Wrong Answer

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


def solve(A: int, B: int, N: int):
    result1 = A - int(A/B)
    result2 = int(A*N/B) - A*int(N/B)
    print(min(result1, result2))
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

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

nextN = N / 2
r = N / 2

n1 = nextN - r / 2
n2 = nextN
n3 = nextN + r / 2

while r > 100:

    c1 = (A * n1 / B) - (A * (n1 / B))
    c2 = (A * n1 / B) - (A * (n1 / B))
    c3 = (A * n1 / B) - (A * (n1 / B))

    m = max([c1, c2, c3])
    if m == c1:
        nextN = int(n1)
    elif m == c2:
        nextN = int(n1)
    else:
        nextN = int(n1)

    r /= 2

    n1 = nextN - r / 2
    n2 = nextN
    n3 = nextN + r / 2

n1 -= 200
n3 += 200
if int(n1) <= 0:
    n1 = 1
if int(n3) > N:
    n3 = N

m = 0

for x in range(int(n1), int(n3)+1):
    c = (A * x // B) - (A * (x // B))
    if c > m:
        m = c

print(m)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
t = N // B
if N % B == 0:
    a = max(0, N-1)
    b = N
    d = max(0,t*B-1)
    e = 1
    f = 0
else:
    a = max(0, t * B - 1)
    b = N
    d = max(0,N-1)
    e = 1
    f = 0

k = A * N // B
if A * N % B == 0:
    case = [a, b, max(min(B-1,N),0),d,e,f]
else:
    c = max(1,k*B//A+1)
    case = [a,b,c,max(min(B-1,N),0),d,e,f]

ans = 0
for i in case:
    ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))

print(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 > ans:
        ans = ansX
    elif ansX == ans:
        break
        
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A , B , N = list(map(int,input().split()))
S=list()
T=list()
for i in range(0,N+1):
  a= (A*i/B)
  if a >=0:
    a=a//1
    S.append(a)
  if a<0:
    a=(a//1)-1
    S.append(a)

for i in range(0,N+1):
  b= (i/B)
  if b>=0:
    b=b//1
    T.append(b)
  if b<0:
    b=(b//1)-1
    T.append(b)


M=(max(S)-A*min(T))
print(math.floor(M))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,N=map(int,input().split())
for i in range(1,N+2):
    d=((a*i)//b)-(a*(i//b))
    if(i>N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break
    if(N==0):
        print(N)
        break

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 and Npower < 12:
    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())

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

Submission status: Wrong Answer

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

x = 0
k = 0
while x<n:
    x += b/a
    k += 1
    print(x,k)
print(k-1)

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=1000000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))
if n%2==0:
    nmid=n/2
if n%2==1:
    nmid=n+1/2
for i in range(n):
    if i>teisuu:
        break
    temp=nmid-i
    maxtemp=max(maxtemp,funcsum(temp))

for i in range(n):
    if i>teisuu:
        break
    temp=nmid+i
    maxtemp=max(maxtemp,funcsum(temp))
print(maxtemp)

#items=[int(i) for i in input().split()]


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
m = -10**12
for x in range(1, n+1):
    i = math.floor(a*x/b)
    j = math.floor(x/b)
    if i-j > m:
        m = i-j
print(m)

Submission status: Wrong Answer

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

max_num = -1
tmp = 0
for x in range(n+1):
  tmp = (x / b - x // b) * a
  if max_num > tmp:
    max_num = x - 1
    break

if (max_num == -1):
  max_num = n
  
print(int(a * max_num / b // 1 - a * (max_num / b // 1)))

Submission status: Wrong Answer

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

if a % b == 0:
  print(0)
else:
  if n % b == 0:
    x = n - 1
  else:
    x = n

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 6000000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 6000000
	for x in range(0,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

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

print(ans)

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:
    if N % B == 0:
        x = N-1
        print(math.floor(A*x/B) - math.floor(x/B)*A)
    else:
        p = N // B
        x = p*B - 1
        print(math.floor(A*x/B) - math.floor(x/B)*A)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N <= 5000000:
    for x in range(1, N+1):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)
else:
    for x in range(1, 600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = N//2-300000
    for x in range(base, base+600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = A//2-300000
    for x in range(base, base+600000):
        if x > N:
            break
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

    base = B//2-300000
    for x in range(base, base+600000):
        if x > N:
            break
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

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

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 1, -A):
        tmp = (A * i // B) - A * (i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

max_v = 0

if N < B:
    max_v = calc(N)
else:
    max_v = calc(B)

# for x in range(N+1):
#     print(x,max_v) # x＝Bでさちる
#     max_v = max(max_v, calc(x))

print(max_v)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
c=max(0,a//b)
d=min(b,n)
def floor(x):
    return int((a*x)/b)-a*(int(x/b))
if n<=b:
    print(floor(n))
else:
    if b<a:
        print(floor(b-1))
    elif b==a:
        print(floor(b))
    else:
        e=max(b-1,a//b)
        print(floor(e))

Submission status: Wrong Answer

Solution code:
def floor(t):
    import math
    return math.floor(t)

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

n = [int(x) for x in range(1,N+1)]

answer_list=[]
for x in n:
    answer = floor(A*x/B) - floor(x/B)
    answer_list.append(answer)
print(max(answer_list))

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)
syou = n/b
if syou >= 1:
    Max = max(f(syou*b-1),f(n))
else:
    Max = f(n)
print(Max)

Submission status: Wrong Answer

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

floor1 = int(a*n/b)
floor = n
for i in range(n):
    i = i+1
    if floor > int(i/b):
        floor = int(i/b)
floor2 = a*floor
print(floor1-floor2)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An =fl(N)
    
if B <=N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) < fl(i-1) :
            An = fl(i-1)
            break

print(str(An))

Submission status: Wrong Answer

Solution code:
import math

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

ans = math.floor((A)/B) - A * math.floor(1/B)
MaxAns = ans
for x in range(N, 2, -1):
    ans_swp = math.floor((A*x)/B) - A * math.floor(x/B)
    if MaxAns < ans_swp:
        MaxAns = ans_swp

    if ans > ans_swp:
        break
    else:
        ans = ans_swp

print(MaxAns)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import random

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(800000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

Submission status: Wrong Answer

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

def asahi(i):
  return int(a*i/b)-a*int(i/b)

print(max(asahi(n),asahi(n-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = (N+1)//B

print(max(((A*B*k)-A)//B - (k-1)*A , A*N//B - A*(N//B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

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

if a == b :
    ans = math.floor(a * (a - 1) / b) - a * math.floor((a - 1) / b)

if a < b :
    # print('a < b')
    # for x in range(n):
    #     temp = math.floor(a * x / b) - a * math.floor(x / b)
    #     print(temp)

    for x in range(b - 1, n + 1, b):
        # print(x)
        temp = math.floor(a * x / b) - a * math.floor(x / b)
        # print(temp)
        if ans <= temp :
            ans = temp

print(ans)

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

if N < B==0:
    ans = int(A*N/B)
else:
    ans = A-1

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
A = []
B = []
C = []

for i in range(n+1):
    tmp = math.floor(a*i/b)
    A.append(tmp)
    temp = math.floor(i/b)
    B.append(temp)

for j in range(n+1):
    t = A[i] - a* B[i]
    C.append(t)

print(max(C))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
    n=N//B
    n=n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)

else:
    ans1 = ans
if N > 100000:
    p = N-100000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(max(ans, ans1))

Submission status: Wrong Answer

Solution code:
import math

A, B, N= (int(x) for x in input().split())
max = 0
x = B * math.floor(N/B) - 1
if x == -1:
    x = N
elif x == 0:
    x = 1
a = math.floor(A * x / B) - A * math.floor(x / B)
b = math.floor(A * N / B) - A * math.floor(N / B)
if a > b:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def calc(x):
    return int(a*x/b) - a*int(x/b)

near_0 =  1/(10**13)
if n <= b:
    print(calc(n))
else:
    print(calc(b-near_0))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if a * n < b:
  print(0)
else :
	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
m = 10000
c = 0
for x in range(1,n+1):
    f = b - x % b
    if m >= f:
        m = f
        c = x
ans = x/b - x//b
print(int(ans*a))

Submission status: Wrong Answer

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

if B==1:
  print(0)

tb = B - 1
tp_pre = 0
while(True):
  tp = (A*tb)//B - A*(tb//B)
  if tp > tp_pre:
    tp_pre = tp
  tb += B
  if tb > N:
    break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


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

    low = 1
    high = N

    ans = fs(A, B, low)

    while abs(low - high) != 1:
        #print(low, high)
        mid = (high + low) // 2
        tmp = fs(A, B, mid)
        if tmp > ans:
            ans = tmp
            low = mid
        else:
            high = mid

    #print(low, high)
    print(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N >= B:
        for x in range(B-1, N+1, B):
            k = x / B
            ans = int(A*k) - int(k)
            if ans > mini:
                mini = ans
    else:
        ans = int(A*(B-1)/B)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

A, B, N = LI()

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

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 and Npower < 12:
    print(N-10**6-10**5-10**4-10**3-10**2)
    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
import itertools
a, b, n = map(int, input().split())
ans = 0
max = 0
for i in range(n+1):
    ans = math.floor(a*i/b)-a*math.floor(i/b)
if(ans > max):
    max = ans

print(max)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
mx=-100000000000
for i in range(n,0,-1):
    k=(a*i//b)-a*(i//b)
    if mx<k:
        mx= max(k,mx)
    else:
        break
print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

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

if a == b :
    ans = math.floor(a * (a - 1) / b) - a * math.floor((a - 1) / b)

if a < b :
    # print('a < b')
    # for x in range(n):
    #     temp = math.floor(a * x / b) - a * math.floor(x / b)
    #     print(temp)

    for x in range(b - 1, n + 1, b):
        # print(x)
        temp = math.floor(a * x / b) - a * math.floor(x / b)
        # print(temp)
        if ans <= temp :
            ans = temp

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

ans = 0

for i in range(n,1,-1):
    tmp = (a*i // b) - (a*(i//b))
    if tmp < ans: break
    ans = tmp
print(ans)

Submission status: Wrong Answer

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

n = b if n > b else n
ans = 0
for x in range(n, 0, -1):
    if x > b:
        continue
    ans = a * x // b
    break

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = list(map(int,input().split()))
if N <= 10000:
    C = [A*i//B-(A*(i//B)) for i in range(1,N+1)]
    print(max(C))
    exit()
C = [A*i//B-(A*(i//B)) for i in range(100)]
D = [A*i//B-(A*(i//B)) for i in range(N,N-100,-1)]
print(max(max(C),max(D)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import random

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

def quick(x):
  pri = math.floor(A * x / B)
  lat = A * math.floor(x / B)
  return math.floor(pri - lat)

max = quick(N)
for i in range(100000):
  ran = math.floor(random.uniform(0, N))
  tem = quick(ran)
  if(max < tem):
    max = tem

print(max)

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]:
    if n >= i and i > 0:
        floor = int(a * i / b) - a * int(i / b)
        ans = max(ans, floor)
for i in range(100000):
    if n >= i and i > 0:
        floor = int(a * i / b) - a * int(i / b)
        ans = max(ans, floor)
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

high = N
low = 0
while high - low > 1:
    mid = (low + high) / 2
    if f(mid) > f(mid - 1):
        low = mid
    else:
        high = mid
print(f(high))

Submission status: Wrong Answer

Solution code:
import math
def C(x):
    return math.floor(A*x / B) - A*math.floor(x/B)

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

high = N
low = 1
x = N//2
result = 1
while True:

    mae = C(x) - C(x-1)
    ato = C(x+1) -C(x)
    if mae > 0 and ato > 0:#単調増加
        low = x +1
        x = (high + low)//2
    elif mae < 0 and ato < 0:#単調減少
        high = x -1
        x = (high + low)//2
    elif mae> 0 and ato < 0:
        result = C(x)
        break
    elif mae == 0 or ato == 0:
        result = C(x)
        break
print(result)

Submission status: Wrong Answer

Solution code:
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,n=map(int,input().split())
if a==1 or b== 1 or n==1:
  print(0)
  exit()

c=lcm(a, b)

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

Submission status: Wrong Answer

Solution code:
import math

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

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

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:
    y = a-1 if a>b else b-1
    x = y if y>n else 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 b <= n:
    print(a-1)
print(int(n % b // (b / a)))

Submission status: Wrong Answer

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

n = n * (n//b) + (n % b)

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

Submission status: Wrong Answer

Solution code:
import math
# ~n,m,q  = map(int,input().split())

# ~seq = [-1]*n;

# ~qs = []
# ~for i in range(q):
	# ~a,b,c,d = map(int,input().split())
	# ~qs.append([a,b,c,d])
# ~qs = sorted(qs, key = lambda x :x[3], reverse = True)


# ~ans = 0

# ~for i in range(q):
	# ~if (seq[qs[i][0]-1] == -1 and seq[qs[i][1]-1] == -1):
		# ~seq[qs[i][1]-1] = qs[i][2]
		# ~seq[qs[i][0]-1] = 1
		# ~ans += qs[i][3]
	# ~else:
		# ~if (seq[qs[i][1]-1] - seq[qs[i][0]-1] == qs[i][2]):
			# ~ans += qs[i][3]
# ~print(ans)

	
	
# ~floor(Ax/B)−A×floor(x/B)

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

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

# ~x = math.ceil((1+2*b)/a)
# ~print(x)


print(f(a,b,n))

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=1000000
def funcsum(x):

    return math.floor(a*x/b)-(a*math.floor(x/b))

for i in range(n):
    if i>teisuu:
        break
    temp=int(n/2)-i
    maxtemp=max(maxtemp,funcsum(temp))

for i in range(n):
    if i>teisuu:
        break
    temp=int(n/2)+i
    maxtemp=max(maxtemp,funcsum(temp))
print(maxtemp)

#items=[int(i) for i in input().split()]


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

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

if B > N:
    print(A*N//B)
else:
    BL = []
    L = []
    b = 1
    while B*b < N:
        BL.append(B*b)
        b += 1
    else:
        BL.append(N)
    for x in BL:
        L.append(A*x//B-A*(x//B))
    print(max(L))

Submission status: Wrong Answer

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

if N%B == 0:
    tmp = (N//B)*B + (N%B)
    print(int(A*(tmp-1)/B) - int(A*int((tmp-1)/B)))
else:
    tmp = (N//B)*B + (N%B)
    print(int(A*(tmp)/B) - int(A*int((tmp)/B)))

Submission status: Wrong Answer

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

cnt = 1
buf = []
while True:
    x = cnt * b - 1
    if n < x or 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:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
x3 = N-C
if x2 < 0:
    x2 =0
def f(x):
    return math.floor(A*x/B)-A*math.floor(x/B)

print(max(f(x1), f(x2), f(x3)))