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

Submission status: Wrong Answer

Solution code:
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B,N = LMIIS()
    if N>= B-1:
        print((N+1)//B*B-1)
    else:
        ans = 0
        for i in range(max(0,N-10**7),N+1):
            ans = max(floor(A*i/B)-A*floor(i/B),ans)
        print(ans)


    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
ans = 0
C = A/B
for x in range(1, A+1):
    ans = max(floor(C*x)-A*floor(x/B), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N = [int(e) for e in input().split()]
t = N[2]//N[1]
ans = (N[0]*N[2])//N[1] - N[0]*(t//N[1])
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A*2):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
a,b,n=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
import math
if n <b:
    x=n
    ans=math.floor(a*x/b)
else:
    ans=0
print(ans)

Submission status: Wrong Answer

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

L = []
if B > N:
    for x in range(1,N+1):
        L.append(A*x//B)
    print(max(L))
else:
    for y in range(1,B+1):
        L.append(A*y//B)
    print(max(L))

Submission status: Wrong Answer

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

if n % 2 == 0:
  print((a * (n-1) // b) - (((n-1) // b) * a))
elif n % 2 == 1:
  print((a * (n) // b) - (((n) // b) * a))

Submission status: Wrong Answer

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

import math

alist=[]
xlist=[]
x=0
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)

x=1
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)

if N>=B:
    x=B-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)

    x=B*(N//B)-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)

x=N
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)

print(max(alist))

Submission status: Wrong Answer

Solution code:
import numpy as np
A,B,N=map(int,input().split())
x = np.array([j for j in range(B+1)])
val=np.floor(A*x/B)-A*np.floor(x/B)
print(int(np.max(val)))

Submission status: Wrong Answer

Solution code:
import math

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

print(math.floor(A*N/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])

if B<=N:
    K = B
else:
    K = N
print(int(A * K / B) - A * int(K / B))

Submission status: Wrong Answer

Solution code:
import math
a, b, n = [int(i) for i in input().split(' ')]
if n > b:
  x = b - 1
else:
  x = n
f = math.floor(a * x / b) - a * math.floor(x / b)
print(f)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
if B == 1:
    max = 0
elif B >= N:
    x = N
    max = ((A * x) // B) - A * (x // B)
else:
    x = B * (N // B) -1
    max = ((A * x) // B) - A * (x // B)
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect  # 二分探索の公式のライブラリをimportする
# A, B, N = map(int, input().split())
# ans = (int(A*N/B) - A*int(N/B))
# # シミュレーション
# for i in range(max(N-1000005, 0), N+1):
#     ans = max(ans, int(A*i/B)-A*int(i/B))
# print(ans)


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

l = 0  # 最初の下界
r = N+1  # 最初の上界
ans = 0
while r - l > 1:  # rとlが交わることがあれば終了
    mid = (l+r) // 2  # 中央値, 選ぶ候補になっている値
    tmp = int(A*mid/B) - A*int(mid/B)
    if tmp >= ans:
        ans = tmp
        l = mid  # 下界をあげる
    else:
        r = mid  # 上界を下げる
#     print(l, r)
# print(l, r)
print(max(ans, int(A*N/B)-A*int(N/B)))

Submission status: Wrong Answer

Solution code:
# Code for D - Floor Function
# Use input() to fetch data from STDIN
from math import floor

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

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

print(min(f(-1), f(n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

left = 0
right = N

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


print(target(right))

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

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

def solve(a,b,n):
	x = n-1
	if(b > n):
		x = n
	return f(a,b,x)


a,b,n = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b,n)
print(ans)

Submission status: Wrong Answer

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

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 340000000:
    break
if N >= 100000000000:
  print(mx-1)
else: 
  print(mx)

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    a,b,n  = map(int, input().split())
    maemax=math.floor(a*n/b)
    ushiromax=math.floor(n/b)
    i=math.floor(maemax*b/a)-1
    j=math.floor(ushiromax*b)-1
    if j<=i:
        print(maemax-ushiromax)
    else:
        print(math.floor(j*a/b)-mathfloor(j/b))
resolve()

Submission status: Wrong Answer

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


x = b-1

if b > n:
  res = int(a/b)

else :
  res = int((a/b)*(b-1))
  
print(res)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -100
for x in range(1, n+1):
    if x % b == 0:
        continue
    fx = int(a*x/b) - a * int(x/b)
    if ans < fx:
        ans = fx
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = (int(i) for i in input().split())
max_num = -10**100
tmp_num = 0
cnt = 1
flg = False
while flg  == False:
  tmp_num = math.floor(A*cnt/B) - A*math.floor(cnt/B)
  #print(tmp_num)
  if tmp_num > max_num :
    max_num = tmp_num
    cnt += 1
  else:
    flg = True
  if cnt > N:
    flg = True
print(max_num)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(floor(floor(a*c/b)-a*floor(c/b)))

Submission status: Wrong Answer

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 6:
    diff = N-500000
    for i in range(0,500000):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
    for i in range(diff,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
print(maxi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
li=[]
for i in range(1,n+1):
  li.append(int(a*i/b)-5*int(i/b))
print(max(li))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
a,b,n=map(int,input().split())
i=n
x=(a*i)//b-a*(i//b)
i=b-1
y=(a*i)//b-a*(i//b)
print(max(x,y))

Submission status: Wrong Answer

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

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

ans = -1
x = 0
for x in range(0,min(A,N)+1):
    c = calc(A,B,x)
    if ans >= c or x > N:
        break
    else:
        ans = c
    x+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

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


# n,m,q = input2()
# abcd=[]
# A=[0]*n
# for i in range(q):
# 	abcd.append(input_array())

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

for i in range(1,n+1,b):
	ans=fl(a,b,i)
	if ans> b_ans:
		b_ans=ans
if i<n:
	b_ans=fl(a,b,n)
print(b_ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

if n < b:
    print(math.floor(a * n / b))
    exit(0)
elif n == b:
    print(0)
    exit(0)
print(f(a, b, b - 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
(A,B,N) = map(int,input().split())
start = int(A*N/B)-A*int(N/B)
startx = int(N/B)
flag = 0
for i in reversed(range(1,startx)):

    subans = (int(A*(B*i-1)/B)-A*int((B*i-1)/B))
    if subans <= start:
        flag += 1
    else:
        start = subans
        flag = 0

#    if flag == 2:
#        break

print(start)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for x in range(1, a):
    num = math.floor(a * x / b) - a * math.floor(x / b)
    ans = max(ans, num)

print(ans)

Submission status: Wrong Answer

Solution code:


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

for i in range(n+1,n-a,-1):
    ans = max(ans,(a*i)//b - a*(i//b))

print(ans)

Submission status: Wrong Answer

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

def main():
    A,B,N = map(int,input().split())
    if N-1 >= B:
        ans = cal(A,B,N-1)
    else:
        ans = cal(A,B,N)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = B-C-1
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), 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
Max = 0
e = 1/b
ae = a*e
axb = 0
xb = 0
temp = 0
h_cut = 0
u_cut = 0
for i in range(n+1):
  axb += ae
  xb += e
  h_cut = axb-int(axb)
  u_cut = (xb-int(xb))*a
  temp = int(u_cut-h_cut)
  Max = max(Max, temp)
else:
  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==0:
        m += 1
    ans = floor(a*m/b)-a*floor(m/b)
print(ans)

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:
def val(a, b, x):
	return (a * x) // b - a * (x // b)

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

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

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

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

# a, b, n = 100, 1000, 100000
# if naive(a, b, n) != main(a, b, n):
# 	print(a, b, naive(a, b, n), main(a, b, n))

Submission status: Wrong Answer

Solution code:
ABN = [int(x) for x in input().split()]
y=0
n=[]
 
if ABN[2]>=ABN[1]-1:
  y=ABN[0]-int(float(ABN[0])/float(ABN[1])+1)
else:
  y=int(ABN[0]*ABN[2]/ABN[1])-ABN[0]*int(ABN[2]/ABN[1])
  
print(y)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
import math
c = math.floor(a*n/b)
d = math.floor(n/b)
e = a*d
f = math.floor(a*(b-1)/b)
g = math.floor((b-1)/b)
h = a*g
if n <= b:
  print(c - e)
else:
  print(f - h)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# Problem D - Floor Function

import math

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

# initialization
ans = 0
if N<=B:
    ans = math.floor(A*N/B) - A * math.floor(N/B)
else:
    ans = math.floor(A*(B-1)/B) - A * math.floor((B-1)/B)

# output
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
a, b, n, = map(int, input().split())
if n < b:
    print(int(a*(n)/b)-a*int((n)/b))
    sys.exit(0)
max = 0

row, up = n-b, n
while row <= up:
    mid = (row+up)//2
    if n//b == mid//b:
        up = mid-1
    elif n//b > mid//b:
        row = mid+1
print(int(a*(up)/b)-a*int((up)/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
def func(x):
    return math.floor((A*x)/B) - A * math.floor(x/B)

if N < B:
    print(func(N))
else:
    print(A)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(C):
  ans = math.floor(A*i/B)-A*math.floor(i/B)
  D.append(ans)

print(max(D))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = f(N)
for n in range(N-1,N-10**6-5,-1):
    if n <= 0: break
    ans = max(ans, f(n))
for n in range(1,10**6+5):
    if n > N: break
    ans = max(ans, f(n))

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
if A == B:
    if N >= A:
        print(A-1)
    else:
        print(N)
elif A > B:
    tmp = A / B
    while(tmp < A):
        tmp += (A/B)
    tmp -= (A/B)
    if A // (A // B) < N:
        print(floor(tmp))
    else:
        print(A//B*N)
else:
    if N >= B:
        print(B-1)
    else:
        print(N-(B-A))

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
ans=0
if B!=1:
    while N%B==0:
        N = N-1
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())

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

print(calc(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
if n < b:
    ans = a*n//b
else:
    ans = a*n//b
    ans = max(ans, n/b)
    ans = max(ans, (a*(b*2-1))//b - a)
    li = [1, (1+(n//b))//2, -(-(1+(n//b))//2)]
    for i in li:
        check = (a*(b*(i+1)-1))//b - a*i
        ans = max(ans, check)
    ans = max(ans, (a*n)//b)-a*(n//b)
print(ans)

Submission status: Wrong Answer

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

n = 0

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

print(n)

Submission status: Wrong Answer

Solution code:
A, B, N = list(map(int,input().split()))
def max_val(a, b, n):
  if b > n:
    x = n
  else:
    x = (b-1)
  return max( int(a*x/b) - a*int(x/b), int(a*n/b) - a*int(n/b)) 
print(max_val(A,B,N))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

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

print(max(a*(B-1)-k-1, f(N), 0) if n>0 else f(N))

Submission status: Wrong Answer

Solution code:
import math

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

var = N//B
ans = -1

if var != 0:
    for i in range(N, -1, -var):
        tmp = math.floor(A*i/B) - A*math.floor(i/B)
        ans = max(ans, tmp)
else:
    ans = math.floor(A*N/B) - A*math.floor(N/B)

print(ans)

Submission status: Wrong Answer

Solution code:
def fanc(A,B,x):
  return ((A*x)/B)-A*(x/B);

A,B,N=input().split();
max=0.0;
A=int(A);
B=int(B);
for x in range(int(N)+1):
  ans=fanc(A,B,x);
  if max<ans:
    max=ans;
print(x);

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = map(int, input().split())
def flr(X):
    return floor(a * X / b) - a * floor(X / b)
if b <= n:
    print(flr(b + 0.1))
else:
    print(flr(n + 0.1))

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


print(dammy)

Submission status: Wrong Answer

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

tmp = n//b*b-1
tmp2 = n//b-1
ans = max(int(a*tmp/b)-a*int(tmp/b), int(a*n/b)-a*int(n/b), int(a*tmp2/b)-a*int(tmp2/b))
print(ans)

Submission status: Wrong Answer

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

if n >= b:
    ans = a-1
else:
    ans = 0
    for x in range(0, n+1):
        flour = int((a*x)/b) - a*int(x/b)
        if flour >= ans:
            ans = flour
        
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)

left, right = 0, n
while right > left + 1:
    mid1 = int((right * 2 + left) / 3)
    mid2 = int((right + left * 2) / 3)
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
if f(right) >= f(left):
    print(f(right))
else:
    print(f(left))

Submission status: Wrong Answer

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

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

#for x in range(1, n+1):
#    f = math.floor(a*x/b) - a*math.floor(x/b)
#    print('f =', f)

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

Submission status: Wrong Answer

Solution code:

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

    if B>=N:
        temp = ((A*(B-1))//B) - (A * ((B-1)//B))
        if max > temp:
            max = temp

    print(max)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for x in range(0,b):
    ans =  ((a*x)//b) - (a * (x//b))
    if(ans > ma):
        ma = ans
        

print(ma)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for x in range(max(n-a*2, 0), n+1):
    tmp = math.floor((a*x)/b) - (a * math.floor(x/b))
    if ans < tmp:
        ans = tmp

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*floor(m/b)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################


def main():
    A,B,N=map(int,input().split())
    G=[]
    prev=-inf
    for x in range(0,min(N+1,10**6)):
        num=(A*x)//B - A*(x//B)
        if prev>num:
            break
        else:
            prev=num
            G.append(num)
    ans=max(G)
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
val = (a // b + 1) * b - 1
val_1 = (a // b) * b - 1
max1 = math.floor(a * val / b) - a * math.floor(val / b)
max2 = math.floor(a * val_1 / b) - a * math.floor(val_1 / b)
if val <= n:
    print(max(max1, max2))
elif val_1 > 0 and val_1 <= n:
    print(max2)
else:
    print(math.floor(a * n / b) - a * math.floor(n / b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in reversed(range(1, N+1)):
    ans = (A * i // B) - A * (i // B)
    if ans == 0:
        continue
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(ceil(floor(a*c/b)-a*floor(c/b)))

Submission status: Wrong Answer

Solution code:
A,B,N = 5,7,4
max = 0
A_ = 0
for i in range(1,N+1):
  if  i > 1 and int((A*i) % B) == int((A*i-1) % B):
    continue
  num = int((A * i)/B) - A * int(i/B)
  if num > max:
    max = num
    
    
print(max)

Submission status: Wrong Answer

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

l = 0  # 最初の下界
r = N+1  # 最初の上界
ans = 0
while r - l > 1:  # rとlが交わることがあれば終了
    mid = (l+r) // 2  # 中央値, 選ぶ候補になっている値
    tmp = int(A*mid/B) - A*int(mid/B)
    if tmp > ans:
        ans = tmp
        l = mid  # 下界をあげる
    else:
        r = mid  # 上界を下げる
#     print(l, r)
# print(l, r)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
s = list(map(int,input().split()))

a = s[0]
b = s[1]
n = s[2]
x = 0
if b-1 <= n:
    x = b-1
    ans = math.floor(a*x/b)-n*math.floor(x/b)
else:
    x = n-1
    ans = math.floor(a*x/b)-n*math.floor(x/b)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if n<b:
    x=n
    ans=int(a*x/b)-a*(int(x/b))
    print(ans)
else:
    c=n//b
    x1=n
    x2=c*b-1
    ans1=int(a*x1/b)-a*(int(x1/b))
    ans2=int(a*x2/b)-a*(int(x2/b))
    print(max(ans1,ans2))