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,x = map(int, input().split())
if x < 10:
    print(int(a*x/b)-(a*int(x/b)))
else:
    print(int(a*(b-1)/b)-(a*int((b-1))/b))

# for i in range(1,x+1):
# print(int(a*i/b),a*int(i/b),int(a*i/b)-(a*int(i/b)))

Submission status: Wrong Answer

Solution code:

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

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

main()

Submission status: Wrong Answer

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

from math import floor

if b > n:
   x = n
else:
   x = b

fp = floor(float(a*x/b))
bp = a*floor(float(x/b))
ans = fp - bp
while fp >= 0 and bp <= 0:
   ans = max(ans, fp - bp)
   x -= 1
   fp = floor(float(a*x/b))
   bp = a*floor(float(x/b))

print(ans)

Submission status: Wrong Answer

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

if A == B :
  print(0)
else:
  print(math.floor(N/abs(A-B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

b-=0.000001
if n > b:
  print(val(b))
else:
  print(val(n))

Submission status: Wrong Answer

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

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

if n>b:
  print(func(a,b,b-1))
else:
  print(func(a,b,n))

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(0)
    e = f(N)

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

    ok = 0
    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

    ans = max(l, e, f(ok))
    for i in range(max(0, ok - 10000), min(N + 1, ok + 10000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 10000), min(N + 1, ng + 10000)):
        ans = max(ans, f(i))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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-1000000,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-1000000),min(n+1,a+1000000)):
            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-1000000),min(n+1,b+1000000)):
            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:
import math

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

max=0
x_max=-1

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
max=0
for x in range(1,n):
  co=abs(math.ceil((a*x)/b)-(a*math.ceil(x/b)))
  if(co>max):
    max=co
print(max)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import os
import math

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

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

    max=0.0
    for x in range(10):
        # ans=int(A*x/B)-A*int(x/B)
        min,_=math.modf(x/B)
        # ans=int(A*min)
        # print(min)
        if x==0:
            max=min
        elif min > max:
            max=min
        else:
            break

    print(int(max*A))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

if(b==1):
    print(0)
    exit()

def check(x):
    return int(a*x/b)-a*int(x/b)
    
preans=0
for i in range(n,1,-1):
    ans=check(i)
    if(ans<preans):
        break
    preans=ans
print(preans)

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 == 1000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
mr=0
if B>N:
    for i in range(0,10**5):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)
elif B<=N:
    for i in range(0,10**5):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    for i in range(0,10**5):
        x=B-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)

Submission status: Wrong Answer

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

if b >= n:
    t = int(a * n / b) - a * int(n/b)
    for i in range(100000):
        t_ = int(a * (n+i) / b) - a * int((n+i)/b)
        if t_ > t:
            t = t_
else:
    t = int(a * n / b) - a * int(n/b)
    
print(t)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x=[]
x.append(int(a*n/b)-a*int(n/b))
while n>b:
  t=int(n/b)
  x.append(int(a*(t*b-1)/b)-a*int((t*b-1)/b))
  n-=b
print(max(x))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

    if var != math.floor(i/B):
        break
    var = math.floor(i/B)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
saidai = 0
if N <= 10**6:
    S = 0
else:
    S = N - 10**6
    
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:
from math import floor
A,B,N  = map(int,input().split())
num = (floor((A*N)/B) - (A * floor(N/B)))
for x in range(0,N+1)[::-1]:
    tmp = floor((A*x)/B) - (A * floor(x/B))
    if num < tmp:
        num = tmp
    elif tmp < num:
        break
print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
ABN = [int(x) for x in input().split()]
y=0
n=[]
if int((ABN[2]+1)/ABN[1])>=1:
  n.append(ABN[1]*int((ABN[2]+1)/ABN[1])-1)
if len(n)==0:
  n.append(ABN[2])
for x in n:
  if y<int(ABN[0]*x/ABN[1])-ABN[0]*int(x/ABN[1]):
    y=int(ABN[0]*x/ABN[1])-ABN[0]*int(x/ABN[1])
  
print(y)

Submission status: Wrong Answer

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

def calc(a, b, x):
    # print(a, b, x, math.floor(a*x/b), math.floor(x/b))
    return math.floor(a*x/b) - a * math.floor(x/b)
    
ans = -1
for x in range(1, n+1)[::-1]:
    r = calc(a, b, x)
    if r > ans:
        ans = r
        break

if ans == -1:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

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


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

if A == B:
    if N%2:x = N//A - 1
    else:x = N//A
    print(f(x))


else:
    left = 1
    right = B-1

    left_res = 0
    right_res = 0

    while left != right:
        left_res = f(left)
        right_res = f(right)
        mid = (left + right)//2
        if left_res > right_res:
            right = mid-1
        else:
            left = mid +1

    print(max(f(left_res),f(right_res)))

Submission status: Wrong Answer

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

b-=0.000001
print(max(val(n), val(b)))

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()
b_ans=fl(a,b,n)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
if a*n/b < 1:
    print(math.floor(a*n/b) - a*math.floor(n/b))
else:
    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)
        else:
            break
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#D
a,b,n = map(int,input().split())
x = n-1
ans1 = ((a*x)//b) - (a*(x//b))
x = n-1
ans2 = ((a*x)//b) - (a*(x//b))
x = n-b
ans3 = ((a*x)//b) - (a*(x//b))
x = n//b
ans4 = ((a*x)//b) - (a*(x//b))
x = n//2
ans5 = ((a*x)//b) - (a*(x//b))
x = 1
ans6 = ((a*x)//b) - (a*(x//b))
print(max(ans1,ans2,ans3,ans4,ans5,ans6))

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    ans = math.floor((A * N) / B) - A * math.floor(N / B)
    print(ans)
else:
    underB = math.floor((A * (B - 1)) / B) - A * math.floor((B - 1) / B)
    eqB = 0
    eqN = math.floor((A * N) / B) - A * math.floor(N / B)
    print(max(underB, eqB, eqN))

Submission status: Wrong Answer

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

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

t1 = f(a, b, n)
t2 = f(a, b, n - n%b - 1)
t = max(t1, t2)

print(t)

Submission status: Wrong Answer

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

def getmax(A,B,N):
    x1 = B * (N//B) - 1
    x2 = N

    resx1 = int(A*x1/B) - A* int(x1/B)
    resx2 = int(A*x2/B) - A* int(x2/B)

    return max(resx1, resx2)

print(getmax(A,B,N))

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:
a, b, n = map(int, input().split())

from math import floor

if b > n:
   x = n
else:
   x = b


ans = 0
fp = floor(float(a*x/b))
bp = a*floor(float(x/b))
while fp >= 0 and bp <= 0:
   ans = max(ans, fp-bp)
   x -= 1
   fp = floor(float(a*x/b))
   bp = a*floor(float(x/b))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0

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

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 == 100000:
    break
print(mx)

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n, max(-1, n - a * 10 - 1), -1):
    ans = max(ans, floor(a * x / b) - a * floor(x / b))

print(max(int(ans),0))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if (n<=b):
    print(a*n//b)
else:
    print(a*(b-1)//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 > 1:
    S /=10
    Npower += 1
if Npower >= 6:
  diff = N-100000
for i in range(diff,N+1):
    maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
print(maxi)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

    def c(x):
        return (A*x)//B - A*(x//B)

    def bin(a):
        left = -1
        right = A + 1

        while(right-left > 1):
            mid = (right+left) // 2
            x = c(mid)
            if x == a:
                return mid
            elif x < a:
                left = mid + 1
            else:
                right = mid - 1

        return -1


    for _a in range(A+1):
        a = A - _a
        x = bin(a)
        # print(x,c(x),a)
        if 0<=x<=N and c(x) == a:
            print(a)
            exit()


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

ans = 0
if N == max(A, B, N):
    ans = (A*N//B)-A*(N//B)
else:
    if N <= 100000:
        for x in range(1, N+1):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(N-100000, N):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:

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

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

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import floor
from functools import reduce
from itertools import product

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

  maximam = 0
  for n in range(1, N+1):
    result = (floor(A*n/B) - A * floor(n/B))
    if maximam < result :
      maximam = result

  print(result)

if __name__ == "__main__":
  resolve()

Submission status: Wrong Answer

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

if b>n:
    print((a*n)//b)
else:
    p=-1
    for i in range(n):
        c=(a*(n-i))//b
        d=((n-i)//b)*a
        q=c-d
        if q>p:
            p=q
        if q<p:
            break

    print(p)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
ans=0
p=10**5
if n>=p:
    for i in reversed(range(n-p,n+1)):
        a=math.floor(a*n/b)-a*math.floor(n/b)
        ans=max(ans,a)
else:
    ans=math.floor(a*n/b)-a*math.floor(n/b)
print(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, -min(N, B)):
        tmp = (A * i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

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

cand = []

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

cand.append(calc(0))
cand.append(calc(n))
cand.append(calc(max(0, n-1)))
cand.append(calc(max(0, b*(n//b) - 1)))
cand.append(calc(min(n, max(0, b-1))))

print(max(cand))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(n,n-1000,-1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Wrong Answer

Solution code:
import math

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

if (N < B):
    print(math.floor((A*N)/B) - A*math.floor((N/B)))
else:
    print(math.floor((A*(N-1))/B) - A*math.floor(((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))
        if i == b - n:
            break
    ans = m
print(ans)

Submission status: Wrong Answer

Solution code:
str1 = str(input(' '))
l = str1.split(' ')
a = int(l[0])
b = int(l[1])
n = int(l[2])

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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 solve1(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,curr,ans)
	return ans

def solve2(a,b,n):
	lx = 1
	rx = n
	ans = 0
	while(lx <= rx):
		x = (lx + rx) // 2
		curr = f(a,b,x)
		if(curr >= ans):
			rx = x - 1
			ans = curr
		else:
			lx = x + 1
		# print('#',lx,x,rx,curr,ans)
	return ans


a,b,n = list(map(int, stdin.readline().rstrip().split()))
ans1 = solve1(a,b,n)
ans2 = solve2(a,b,n)
ans = max(ans1,ans2)
print(ans)

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 == 10000:
    break

print(mx)

Submission status: Wrong Answer

Solution code:
import math

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

x = math.ceil(B-1.0*B/A)

if N <= x:
    ans = math.floor(1.0*A*N/B) - A*math.floor(1.0*N/B)
    print(ans)
else:
    ans2 = math.floor(A-1.0*A/B) - A*math.floor(1-1.0/B)
    print(ans2)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if N>=B:
	x=(N//B)*B-1
	t=B-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())
score = 0
max_score = 0
for x in range(b-1, n+1, b):
  score = math.floor(a*x/b) - a*math.floor(x/b)
  if score > max_score:
    max_score = score
for x in range(b*(n//b), n+1):
  score = math.floor(a*x/b) - a*math.floor(x/b)
  if score > max_score:
    max_score = score
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
if N == max(A, B, N):
    ans = (A*N//B)-A*(N//B)
else:
    if N <= 10000:
        for x in range(1, N+1):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(N-10000, N):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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(int(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
    
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(int(boom))

Submission status: Wrong Answer

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

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

for x in range(n, 1, -1):
    if x%b == b-1:
        print(a * x // b - a * (x // b))
        exit()

Submission status: Wrong Answer

Solution code:
#d
A,B,N=map(int,input().split())
a=0
for i in range(N):
    p=(A*i)//B-A*(i//B)
    if p>a:
        a=p
print(a)

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:
#coding: utf-8
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())
max=0
x_max=-1
for x in range(A-3,A+3):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x
for x in range(B-3,B+3):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x
for x in range(N-3,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x
print(max)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
start=1
end=n
ans=0
while start<=end:
	mid=(start)+(end-start)//2
	ans1=math.floor((a*mid)/b)-(a*math.floor(mid/b))
	ans2=0
	if mid>0:
		ans2+=math.floor((a*(mid-1))/b)-(a*math.floor((mid-1)/b))
	ans3=0
	if mid+1<=end:
		ans3+=math.floor((a*(mid+1))/b)-(a*math.floor((mid+1)/b))
	ans=max(ans,ans1)
	ans=max(ans,ans2)
	ans=max(ans,ans3)
	if ans2<=ans3:
		start=mid+1
	else:
		end=mid-1
print(ans)

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

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

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

print(f(x))

Submission status: Wrong Answer

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

def func(x):
    return int(A * x * B ** -1) - A * int(x * B ** -1)

print(func(N))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = int(math.floor(a*n/b)-a*math.floor(n/b))
        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:
from math import floor
a,b,n = map(int,input().split())
ans = 0
t = int(n/max(a,b))+1
if min(a,b) > n:
    for i in range(n+1):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
else:
    for i in range(t+1):
        ans = max(ans,floor(a*i/b) - a*floor(i/b))
print(ans)

Submission status: Wrong Answer

Solution code:
#!python3

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


def f(x):
    ret = int(A * x / B) - A * int(x / B)
    return ret


def main():
    if N <= B:
        ans = f(N)
        print(ans)
        return
    
    a = f(B - 1)
    b = f(N) if N % B != 0 else f(N - 1)
    c = f(N // B * B - 1)
    ans = max(a, b, c)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n-1, max(-1, n - a*10 - 1), -1):
    ans = max(ans, floor(a * x / b) - a * floor(x / b))

print(int(ans))

Submission status: Wrong Answer

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

def fl_m(a,b,n):
  if n>=(a-1)*b/a:
    z=a-1
  else:
    q=b/a
    k=int(n/q)
    z=k
  return(z)
    
print(fl_m(A,B,N))

Submission status: Wrong Answer

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

if A % B == 0:
    print(0)

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

Submission status: Wrong Answer

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