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 == 1:
    print(n)
    exit()

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

print((a * n // b) - a * (n // b))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
result =  [int((a*n)/b)-a*int(n/b)]
n -= 1
while n%b != 0:
    result.append(int((a*n)/b)-a*int(n/b))
    n -= 1
print(max(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = -1
for x in range(n//2,n+1):
    abc = ((a*x)//b)-(a*(x//b))
    print(x ,abc)
    if(ans < abc):
        ans = abc

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
if b >= n:
    x = n
    ans = int(a * x // b) - int(a * (x // b))
else:
    m = 0
    for i in range(b):
        if int(a * (n - i) // b) - int(a * ((n - i) // b)) > m:
            m = int(a * (n - i) // b) - int(a * ((n - i) // b))
    ans = m
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

def main():
    A, B, N = list(map(int, input().split(' ')))
    
    tmp = 0
    
    for x in range(1, N+1):
        out = floor(A * x / B) - floor(x / B)
        tmp = max(tmp, out)
    print(tmp)
    
    
main()

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
while True:
    if n % b == 0:
        break
    n -= 1
print(int(a*(n)/b)-a*int((n)/b))

Submission status: Wrong Answer

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

c = N // B
d = N % B

ans1 = int(A / B * N)
ans2 = 0

if c != 0:
    ans2 = int(A / B * (B-1))
ans = max(ans1, ans2)


print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    A , B, N = map(int, input().split())
    old = 0
    new = 0
    frag = 0
    for x in range(1,N+1) :
        new = (A * x) // B
        #print(new)
        value = (int(A*x // B) - int(x // B))
        #print(value)
        if new == old and frag == 0 :
            #print("a")
            pass
        elif new > old and  value > 0 and x != N :
            #print("b")
            frag = 1
        elif new == old and frag == 1 :
            #print("c")
            print(value)
            break
        else :
            #print("d")
            print(value)
        old = new



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


ans = (a*n)//b-a*(n//b)
if n >= 1:
    ans2 = (a*(n-1))//b - a*((n-1)//b)
else:
    ans2 = 0
if n >= 2:
    ans3 = (a*(n-2))//b - a*((n-2)//b)
else:
    ans3 = 0
if n >= 3:
    ans4 = (a*(n-3))//b - a*((n-3)//b)
else:
    ans4 = 0
print(max(ans,ans2,ans3,ans4))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
ans = 0
if n <= 1000000:
    for i in range(1,n+1):
        k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
else:
    if n <= a or n <= b:
        for i in range(n-100,n+1):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
    elif a <= b:
        for i in range(max(1,a-100),a+1):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
    elif a > b:
        for i in range(max(1,b-100),b+1):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
print(ans)

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B,N = map(int,input().split())
ans = 0
for i in range(A):
    if N < i:
        break
    t = (A*i) // B - A * (i//B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans < t :
        ans = t
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

max = -1
for i in range(N, -1, -1):
    tmp = math.floor(A*i/B) - A*math.floor(i/B)
    if max < tmp:
        max = tmp
    elif max > tmp:
        break

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


ans = a * n // b - a * (n // b)
print(int(ans))

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 = 1
r = n
while r - l > 1:
    x = (r + l) // 2
    if calc(x) < n:
        l = x
    else:
        r = x
print(calc(r))

Submission status: Wrong Answer

Solution code:
# map(int,input().split())
# int(input())
import math
a,b,c = map(int,input().split())
# if a< b 定まらん
# if a>=b a-1
# cの値による？c <= a-2 のとき.
maxcnt = -99999
for x in range(min(c + 1, a)):
	cnt = math.floor(a * x / b) - a * math.floor(x / b)
	if cnt > maxcnt:
		maxcnt = cnt
print(maxcnt)

Submission status: Wrong Answer

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

s1 = math.floor(a * n / b) - a * math.floor(n / b)
if n <= b:
    print(s1)
    exit()

ans = 0
for i in range(b, b - 10*3, -1):
    ans = max(math.floor(a * (b-1) / b) - a * math.floor((b-1) / b), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
list = []

for i in range(N+1):
    list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(list[len(list) - 1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


    return ans


print(solve())

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(max(((n-1)*a)//b - a*((n-1)//b),(n*a)//b - a*(n//b)))

Submission status: Wrong Answer

Solution code:
import sys

def floor(A, B, X):
    return(int(A * X / B) - (A * int(X / B)))

A, B, N = map(int, sys.stdin.readline().split())
print(floor(A, B, B - 1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a, b, N = map(int,input().split())
ans = 0
for i in range(1,min(N+1,100000)):
    g = (a*i) // b - a * (i // b)
    #print(g)
    ans = max(ans,g)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y

if b > n:
    print(func(n))
else:
    while True:
        if n %b == b-1:
            print(func(n))
            break
        else:
            n -= -1

Submission status: Wrong Answer

Solution code:
import math
def floorfunction(A,B,x):
  sTgt=math.floor(A*x/B)-A*math.floor(x/B)
  return sTgt
  
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  for i in reversed(range(1,N+1)):
    sTgt=floorfunction(A,B,N)
    if(i==N):
      sMax=sTgt
    else:
      sMax=max(sMax,sTgt)
    if(i%B==0):
      sCount=sCount+1
    if(sCount>=2):
      break
  print(int(sMax))
  
if __name__=='__main__':
  main()

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
for i in range(n):
  i += 1  
  axb += ae
  xb += e
  temp = int(axb)-a*int(xb)
  Max = max(Max, temp)
  if Max != temp:
    print(Max)
    break
else:
  print(Max)

Submission status: Wrong Answer

Solution code:
import math


A, B, N = map(lambda x: int(x), input().split(" "))

result = 0
candidate = -1
for i in reversed(range(0, N+1)):
    if i % B == 0:
        candidate= i-1
if candidate > 0:
    i = candidate
    temp = math.floor(A*i/B) - A*math.floor(i/B)
    result = max(result, temp)

temp = math.floor(A*N/B) - A*math.floor(N/B)
result = max(result, temp)

print(result)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input('').split(' '))
r=0
m=0
for i in range(b):
    if r>=n:
        break
    s=int(a*r/b)
    if s>m:
        m=s
    
    r=r+1
print(int(a*r/b))

Submission status: Wrong Answer

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

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

Submission status: Wrong Answer

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


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

left,right=0,n
while right>left+0.00001:
    mid1=(right*2+left)/3
    mid2=(right+left*2)/3
    if f(mid2)>f(mid1):right=mid1
    else:left=mid2

print(f(left))

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B,N = map(int,input().split())
ans = 0
for i in range(A):
    if N < A:
        break
    t = (A*i) // B - A * (i//B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans < t :
        ans = t
print(ans)

Submission status: Wrong Answer

Solution code:
def main(a: int, b: int, n: int):
    ans = 0
    for i in (1, n):
        f = int((a * i) / b) - a * int(i / b)

        if ans < f:
            ans = f

    print(ans)


if __name__ == "__main__":
    a, b, n = map(int, input().split())
    main(a, b, n)

Submission status: Wrong Answer

Solution code:
a,b,n = [int(_) for _ in input().split()]

ans = []
for x in reversed(range(n-3,n+1)):
  ans.append((a*x)//b - a * (x//b))

print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# D - Floor Function

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

X = min(B, N)

print((A*X)//B - A*(X//B))

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:55:57 2020

@author: Kanaru Sato
"""

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
x = 0
Vmax = 0 
for i in range(N+1):
  if A * int((i%B)/B) - int(((A*i)%B)/B) >= Vmax:
    x = i
    Vmax = A * int((i%B)/B) - int(((A*i)%B)/B)
print(int(A*x/B)-A*int(x/B))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
p = 1
ans = list()
if n <= b:
    print(a*n//b)
else:
    while p*b < n:
        ans.append((a*(((p+1)*b-1)//b)-p))
        p += 1
    print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inp=[int(x) for x in input().split()]
a,b,n=inp[0],inp[1],inp[2]
if (a-1)>n:
  print(n-1)
else:
  print(a-1)

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):
	lx = 1
	rx = n
	ans = 0
	while(lx <= rx):
		x = (lx + rx) // 2
		curr = f(a,b,x)
		if(curr >= ans):
			lx = x + 1
			ans = curr
		else:
			rx = x - 1
		# print(lx,x,rx)
	return ans


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

Submission status: Wrong Answer

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


ans = floor(a * n / b) - a * floor(n / b)
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
ans=0
a,b,n=map(int,input().split())
st=1
if n>10000001:
    st=n-a*10
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

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

if N <B:
	print(int(math.floor(A*N/B)))
	exit()
    
if N%B==0:
	print(0)
	exit()

nagasa = int(math.floor(N/B))+1

k = [0]*nagasa

for i in range (0, nagasa):
	k[i] = (i+1)*B-1

k[-1] = N
print(k)
    
boom=0

for i in range (0, nagasa):
	p = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
	if p> boom:
		boom = p

print(boom)

Submission status: Wrong Answer

Solution code:
A,B,N = (int(x) for x in input().split())
x = N/2
ans = -1
length = int(N/4)
while(x > 2):
    ans1 = int(A*x/B) - A*int(x/B)
    ans2 = int(A*(x+1)/B) - A*int((x+1)/B)
    if(x == N):
        if(ans1 > ans):
            ans = ans1
        break
    elif(ans1 > ans2 and ans1 > ans):
        ans = ans1 
        x = ans -length
    elif(ans2 > ans1 and ans2 > ans):
        ans = ans2
        x = ans + length
    else: 
        break
    length = int(length/2)
for i in range(min(6,N)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    f = lambda x: int(A*x/B) - A * int(x / B)

    if B == 1:
        print(0)
    else:
        ans = 0
        x = max(B * (N // B) - 1, N)
        ans = max(f(x), ans)
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
def floor(x):
  return (x//1)
list = []
for x in range(B):
    list.append(floor((A*x)/B)-(A*floor(x/B)))
print(int(max(list)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for x in range(n+1)[::-1]:
    if ans > ((a*x//b)-(x//b)*a):
        ans = max(ans, (a*x//b)-(x//b)*a)
        break
    else:
        ans = max(ans, (a*x//b)-(x//b)*a)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

p = N*(N%B)-1

for i in range(N,1,-1):
    if i%B==0 and B!=1:
        continue
    else:
        ans=math.floor(A*i/B)-A*math.floor(i/B)
        break

if ans<math.floor(A*p/B)-A*math.floor(p/B):
    ans=math.floor(A*p/B)-A*math.floor(p/B)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


    def f(m):
        return (A * m) // B - A * (m // B)



    l = f(1)
    e = f(N)
    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False

    ok = 1
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid


    print(max(l, e, f(ok), f(max(0, ok - 1)), f(min(N, ok + 1))))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

left,right=0,n
while right>left+1:
    mid1=(right*2+left)/3
    mid2=(right+left*2)/3
    if f(mid2)>f(mid1):right=mid1
    else:left=mid2

print(f(left))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def solve(a, b, n):
    return math.floor(a * n / b) - a * math.floor(n / b)

if __name__ == "__main__":
    a, b, n = map(int, input().split(' '))
    print(solve(a,b,n))

Submission status: Wrong Answer

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

print(int((a * n) / b) - a * int(n / b))

Submission status: Wrong Answer

Solution code:
import math

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

n = min(n, 10**6)

num = 0
for x in range(1, n+1):
    if num <= math.floor(a*x/b) - a*math.floor(x/b):
        num = math.floor(a*x/b) - a*math.floor(x/b)
    else:
        break

print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if N<=10**6:
    ans=0
    for x in range(1,N+1):
        ans=max(ans,((A*x)//B)-A*(x//B))
    print(ans)
elif B<=10**6:
    ans=0
    for x in range(1,min(B+1,N+1)):
        ans=max(ans,((A*x)//B)-A*(x//B))
    print(ans)
elif B>=A:
    x=0
    ans=0
    y=0
    while(x<=N):
        ans=max(ans,((A*x)//B)-A*(x//B))
        y+=1
        x=(B*y)//A
    print(ans)
else:
    ans=0
    for x in range(1,min(B+1,N+1)):
        ans=max(ans,((A*x)//B)-A*(x//B))
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b,n=list(map(int,input().split()))
if n<b:
    print(math.floor(a*n/b))
    exit()

print(a-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

maxFloor = 0

def floor(x):
    num = int(x // 1)
    return num

check = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
print(check)

Submission status: Wrong Answer

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

for x in range(min(b, n), 0, -1):
    score = int(a*x/b) - a*int(x/b)
    if (score > 0):
        print(score)
        break

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:
import math as m
a,b,n  = map(int,input().split())
print((m.floor((a*n)/b) - (a*(m.floor(n/b)))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int, input().split())
import math
max=0
for x in range(10**6):
  y=math.floor(A*x/B)-A*math.floor(x/B)
  #print(y)
  if max<y:
    max=y
   # print(x,math.floor(A*x/B),A*math.floor(x/B),y)
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

cands = []
temp = math.floor(A * N / B) - A * math.floor(N / B)
cands.append(temp)
if B <= N :
    temp = math.floor(A * (B - 1) / B) - A * math.floor((B - 1) / B)
    cands.append(temp)
print(max(cands))
# 
# 
# cand = A * N //B
# cand2 = cand - 1
# ma = 0
# for x in range(1,N + 1):
#     temp = math.floor(A * x / B) - A * math.floor(x / B)
#     ma = max(temp,ma)
#     # print(math.floor(A * x / B),A * math.floor(x / B),x,temp)
# print(ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    import random

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
print(max(floor(A*N/B)-A*floor(N/B),floor(A*B/B)-A*floor(B/B)))

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int, input().split())
m = A//B
a = A%B
x = max(N,B-1)
print(m*x+floor(a*x/B))

Submission status: Wrong Answer

Solution code:
import math

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

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

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

for i in range(n):
    if i<teisuu:
        break

    maxtemp=max(maxtemp,funcsum(i))
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 sys
from itertools import combinations_with_replacement
def input(): return sys.stdin.readline().strip()


def main():
    A, B, N = map(int, input().split())
    r = min(N % B, (B - 1)) / B
    print(int(A * r))



    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

A,B,N = LI()

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

Submission status: Wrong Answer

Solution code:
from math import floor
def seq(a, b, x):
    return int(floor((a*x)/b)) - int(a*floor(x/b))
ma = 0
a, b, n = map(int, input().split())
for i in range(int(1e6)+1):
    ma = max(ma, seq(a, b, i))
print(ma)

Submission status: Wrong Answer

Solution code:
from math import floor


def main():
    A, B, N = map(int, input().split())
    # A, B, N = 5, 7, 4

    ans = 0
    for x in range(N + 1):
        # x = 3
        val = floor(A * x / B) - A * floor(x / B)
        if val > ans:
            ans = val
    print(val)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
xnum=0
if N >10**5:
    N = 10**5

for x in range(N):   
    if math.floor((x*A)/B)-A*(math.floor(x/B))>ans:
        ans = math.floor((x*A)/B)-A*(math.floor(x/B))
        xnum=x
        
print(ans)

Submission status: Wrong Answer

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

s1 = math.floor(a * n / b) - a * math.floor(n / b)
if n <= b:
    print(s1)
    exit()

s2 = math.floor(a * (b-1) / b) - a * math.floor((b-1) / b)
print(s2)

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

Submission status: Wrong Answer

Solution code:
import sys
import math

if __name__ == '__main__':
    a, b, n = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    # for x in range(n+1):
    #     print(math.floor(a*x/b)-a*math.floor(x/b))

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

Submission status: Wrong Answer

Solution code:
import math


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

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

    max_value = -1
    max_x = -1
    for i in range(1, min(10**6, N)+1):
        v = target(i)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_x = i
            max_value = v

    # print(max_x)
    print(max_value)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(a*n//b - a*(n//b))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import random

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

for i in range(10 ** 6):
    num = random.randint(0,n)
    ans = max(ans,(a * num)//b - a * (num//b))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
line = input()
a, b, n = line.split(" ")
a, b, n = int(a), int(b), int(n)
ans = 0

ans_list=[]
for i in range(n+1):
    ans = math.floor((a*i)/b) - math.floor(i/b)
    ans_list.append(ans)
print(max(ans_list))

Submission status: Wrong Answer

Solution code:
import math

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

n = min(n, 10*6)

num = 0
for x in range(1, n+1):
    if num <= math.floor(a*x/b) - a*math.floor(x/b):
        num = math.floor(a*x/b) - a*math.floor(x/b)
    else:
        break

print(num)

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = [int(x) for x in input().split()]
def e(x):
	return floor(a * x / b) - a * floor(x / b)
x = min(b - 1, n)
v1 = e(x)
x = n
v2 = e(x)
v3 = e(min(b, n))
print(max(v1, v2, v3))