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:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
for i in range(n,0,-1):
    ans = math.floor(a*i/b)-a*math.floor(i/b)
    al.append(ans)
    if len(al) > 1:
        if al[-1]<al[-2]:
            break
print(max(al))

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)


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

Submission status: Wrong Answer

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

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

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 = []

if N >= 10:
    for i in range(N-10,N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
    
print(max(list))

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 - 1
    max = ((A * x) // B) - A * (x // B)
print(max)

Submission status: Wrong Answer

Solution code:
a,b,x = map(int, input().split())
point = 0
if x < b:
    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:
import numpy as np
a,b,n=map(int,input().split())
x=np.array([int(i) for i in range(n+1)])
for x1 in x:
    x1=int(a*(x1%b)/b)
print(max(x))

Submission status: Wrong Answer

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

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

def isIncrease(x):
    # math.floor(a * x / b) - a * math.floor(x / b)
    if solve(x) > solve(x-1):
        return True
    else:
        return False

ans = 0

l = 0
# r = 10**12
r = n

while l <= r:
    m = (l+r)//2

    if isIncrease(m):
        l = m + 1
    else:
        r = m - 1

# print(m)
# print(solve(m))

x, y, z = 0, solve(m), 0

if m < n:
    z = solve(m+1)
if m > 0:
    x = solve(m-1)

# ans = max(solve(m-1), solve(m), solve(m+1))
ans = max(x, y, z)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A,B,N = [int(item) for item in input().split()]

    def func(x):
        first = int(A * x / B)
        second = A * int(x/B)
        return first - second

    res = 0

    for i in range(N-10, N+1):
        if i >= 1:
            res = max(res, func(i))
    
    print(res)

if __name__ == "__main__":
    resolve()

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
            old_v = value
        elif new == old and frag == 1 :
            #print("c")
            if old_v > value :
                value = old_v
            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 = int((a*n)/b) - a*int(n/b)

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

print(ans)

Submission status: Wrong Answer

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

for i in range(3,n+1):
    if res_aftr <= res_bef:
        break
    res_bef = res_aftr
    res_aftr = floor(a*i/b) - a * floor(i/b)

print(res_aftr)

Submission status: Wrong Answer

Solution code:
import math
def func(i):
    return math.floor(a * i * 1.0 / b) - a * math.floor(i * 1.0 / b);

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

print (max(func(b), func(n)))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = 0
ans = 0

if N < 1000:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
else:
  for i in range(N-999,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
  for i in range(int(N//2)-100,int(N//2)+100000):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def getmax(A,B,N):
    x1 = max(B * (N//B) - 1, 0)
    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:
import math

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

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

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    a,b,n=map(int,input().split())
    def fl(a,b,x):
        return int(a*x/b)-a*int(x/b)
    x=n
    pretemp=fl(a,b,x)
    prex=0
    nowmax=n
    nowmin=0
    dis=n//2
    i=1
    right=False
    while i<=100000:
        if i%10==0:
            dis=-(dis//(-2))
        if right:
            x+=dis
            if x>n:
                x=n
            temp=fl(a,b,x)
        else:
            x-=dis
            if x<0:
                x=0
            temp=fl(a,b,x)
        if temp>=pretemp:
            pass
        elif temp<pretemp:
            right=(right-1)*(-1)
        pretemp=temp
        i+=1
    if x+1<=n:
        tempup=fl(a,b,x+1)
    else:
        tempup=fl(a,b,x)
    if x-1>=0:
        templow=fl(a,b,x-1)
    else:
        templow=fl(a,b,x)
    temp=fl(a,b,x)
    temp=max(temp,templow,tempup)

    print(temp)


if __name__ == "__main__":

    main()

Submission status: Wrong Answer

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

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

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)
    ans2=int(a*(b-1)/b)-a*int((b-1)/b)
    print(max(ans,ans2))

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())
answer=0
for i in reversed(range(1,N+1)):
    temp=math.floor(A*i/B)-A*math.floor(i/B)
    if answer>temp:
        answer=max(answer,temp)
        break
    else:
        
        answer=max(answer,temp)
    
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

if A*N < B:
    print(0)
    exit()

if N < B:
    print(int((A*N)/B) - A*int(N/B))
    exit()

aa = N//B
x = aa*B - 1
res = int(A*x/B) - A*int(x/B)

print(res)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    # for i in range(n, 1, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    if n // b * b - 1 >= 0:
        n = n // b * b - 1

    # while 1:
    #     if (a * n) % b == 0 and n % b == 0:
    #         n -= 1
    #     else:
    #         break


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

    # print('ans')
    # print(n, ans)
    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

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,i)
    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())
if n < b:
    ans = a*n//b
else:
    ans = a*n//b
    for i in range(1, n//b):
        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:
import math
a,b,n = list(map(int,input().split()))
print("{:}".format(math.floor(a*n/b)-a*math.floor(n/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
for i in range(n):
  axb += ae
  xb += e
  temp = int(axb)-a*int(xb)
  Max = max(Max, temp)
else:
  print(Max)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
#N=int(input())
#A = list(map(int,input().split()))
#S=str(input())
m=0
#if B<N:
#    N=B
if B>A:
    s=int(B/A)
else:
    s=1
for x in range(0,N+1,s):
    num=int(A*x/B) - A * int(x/B)
    #print(num,x)
    m=max(num,m)

print(m)

Submission status: Wrong Answer

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

if b<n:
    i = b-1
    ans = (a*i//b) - a*(i//b)
else:
    i = n
    ans = (a*i//b) - a*(i//b)
# ans = [(a*i//b) - a*(i//b) for i in range(1, min(b, n)+1)]
# print(max(ans))
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(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 - 1000000), min(N + 1, ok + 1000000)):
        ans = max(ans, f(i))
    for i in range(max(0, ng - 1000000), min(N + 1, ng + 1000000)):
        ans = max(ans, f(i))

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

ans =max(floor(A,B,N),floor(A,B,N*(N//B)),floor(A,B,N*(N//B)))


print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int, input().split())
answer=0
import math
Blist=[]
apple=max(B,N)
for i in range(1,apple+1):
    newans=math.modf(i/B)[0]*A
    newans//=1
    answer=newans if newans>answer else answer
print(int(answer))

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:
def main():
    import math
    a, b, n = map(int, input().split())
    ans = 0

    for x in range(n, 0, -1):
        fx = math.floor(a * x / b) - math.floor(x / b) * a
        #print(fx)
        if ans < fx:
            ans = fx
        if ans > fx + 10 ** 3:
            exit()
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

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

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

for x in range(1,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			
print(max)

Submission status: Wrong Answer

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


print((a*n)%b)

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,8))):
  res = max(res,(a*i)//b - a*(i//b))
if n >= pow(10,8):
  print(res+1)
else:
  print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B,N = map(int,input().split())
ans = -100000000000
if A > N:
    for i in range(A):
        t = (A*i) // B - A * (i//B)
    #    print(i, t,(A*i) // B, A * (i//B))
        if ans < t :
            ans = t
    print(ans)
else:
    for i in range(N+1):
        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:
def val(a, b, x):
	return int((a * x) / b) - a * int(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):
	if n % b == 0:
		return val(a, b, n - 1)
	else:
		return max(val(a, b, n), val(a, b, (n // b) * b - 1))

# n = 10000
# for a in range(1, 10):
# 	for b in range(1, 100):
# 		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))

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=[int(i) for i in input().split()]
m=-1
m=max(m,math.floor(a*n/b)-a*math.floor(n/b))
print(m)

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 = (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
print(max_num)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
count = 0
for x in range(N,0,-1):
    floor = math.floor(A*x/B) - A * math.floor(x/B)
    if ans <= floor:
        count = 0
        ans = floor
    elif count > 10000:
        break
    count += 1
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 == 3000000:
    break
print(mx)

Submission status: Wrong Answer

Solution code:
A,B,N=list(map(int,input().split()))
for i in range(N,N+1):
  print(int(A*i/B)-A*int(i/B))

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

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, n // b * b - 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(min(n,666*a)):
	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())

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

st=1
if n>10000001:
    st=n-a*10

for x in range(st,n):
    s=a*(x-math.floor(x/b)*b)/b
    if ans<s:
        ans=s
print(math.floor(ans))

Submission status: Wrong Answer

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

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

#print(max(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print func(N)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

n = 0

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

print(n)

Submission status: Wrong Answer

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

while(x<N):
  if(A*x<B and x<B):
    a=0
  elif(A*x<B and B<=x):
    a=0
  elif(B<=A*x and x<B):
    a=math.floor(A*x/B)
  else:
    a=math.floor(A*x/B)-A*math.floor(x/B)
  if(res<a):
    res=a
  x+=1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=list(map(int,input().split()))
ans=0
#for x in range(n+1):
x=b-1 if n-1>=b else n
ans=max(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 = list(map(int,input().split()))
def max_val(a, b, n):
  x = (b-1)
  return int(a*x/b) - a*int(x/b)    
print(max_val(A,B,N))

Submission status: Wrong Answer

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

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

l = 0
r = n
while r - l > 100:
    rr = (l + 2*r)//3
    ll = (2*l + r)//3
    if f(ll) > f(rr):
        r = rr
    elif f(ll) < f(rr):
        l = ll
    else:
        l = ll - 1

ans = -100000000000
for i in range(l,r+1):
    ans = max(ans,f(i))
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(1,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:
import math

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

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

for x in range(1,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			
print(max)

Submission status: Wrong Answer

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

if b>n:
    print((a*n)//b)
else:
    p=0
    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 sys
from math import floor
import itertools
import collections

def solve(A,B,N):
    if(B > N):
        return floor(A*N/B) - A * floor(N/B)
    else:
        x = N - (N % B + 1)
        return floor(A*x/B) - A * floor(x/B)

def main():
    A,B,N = map(int,input().split())
    # solve()
    print(solve(A,B,N))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

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


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

    val1 = A * N / B
    val2 = N / B
    max_val = int(val1 if val1 > val2 else val2)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

answer = (a*n)//b - a*(n//b)
answer_x = 0

if n > b:
    x = b*(n//b)-1
    answer_x = (a*x)//b - a*(x//b)

answer = max(answer, answer_x)

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, N = MAP()

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

ans = 0
for i in range(1, min(A+1, N+1)):
	ans = max(ans, f(i))
print(ans)

Submission status: Wrong Answer

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

if n >= a:
  ans = (a*b)//7 - 5*(b//b)
  print(ans)
  quit()

ans = (a*n)//b - 5*(n//b)

print(ans)

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

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

if (b < n):
    temp = a * (b - 1) / float(b)
#  ans = math.floor(temp)
else:
    temp = (a * n) / float(b)
   # ans =

ans = math.floor(temp)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

for x in range(n):
    temp = math.floor(a * x / b) - a * math.floor(x / b)

    if ans <= temp :
        ans = temp

print(ans)

Submission status: Wrong Answer

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

#for x in range(n+1):
ans = (int((a*(n))/b) - a * int(n/b))
print(ans)

#print(max(li))