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 sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import math

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

  ans = 0
  for i in [N, N-1, N-2, N-3, N-4, N-5]:
    tmp = math.floor((A*i)/B)-(A*(math.floor(i/B)))
    ans = max(ans, tmp)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B:
    n = int(N/B)
    n = n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
    ans5 = int((A*(n))/B)-A*int((n)/B)
else:
    ans1 = ans
    ans2 = ans
    ans3 = ans
    ans4 = ans
    ans5 = ans


print(max(ans, ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
MAX=[]
if N<B:
    big = math.floor(A*N/B)
    print(big)
else:
    while N>=B:
        ans = math.floor(A*N/B)-A*math.floor(N/B)
        MAX.append(ans)
        N-=1
    print(max(MAX))

Submission status: Wrong Answer

Solution code:
import math
 
A, B, N = map(int, input().split())
c = 0
for x in range(N, 1, -1):
    j = (A*x / B)
    k = (x / B)
    a = math.floor(j) - A * math.floor(k)
    if a <= c :
        break
    c = a
print(c)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6+1:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(N-10**6,N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

a, b, n = map(int, input().split())
n = min(n, 1000000)
ans = max(floor(a*x/b) - a * floor(x/b)  for x in range(1, n+1))
print(ans)

Submission status: Wrong Answer

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

ans = -1
if(a % b == 0):
    x = b-1
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc
elif(n < 10 ** 8):
    for x in range(1,n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(n-(10**6),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
floor_1=int()
floor_2=int()
floor_1=0
floor_2=0
for x in range(1,N+1):
    floor_1=(math.floor((A*x)/B))-(A*(math.floor(x/B)))
    if floor_1>=floor_2:
        pass
    else:
        floor_2=floor_1
print(floor_1)

Submission status: Wrong Answer

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

def ans(k):
    return math.floor(a*k/b)-a*math.floor(k/b)

a1 = ans(-10**-12)
a2 = ans(n)

d = a2/n

x = int(a1/d) if d != 0 else 0
true_x = -1

prev = ans(max(1, x-10000))
lst = [i for i in range(max(1, x-10000), x+10000)]
first=False
for i in lst:
    if ans(i) < prev:
        true_x = i
        break
        
print(a1 if (true_x != -1 and true_x<n) else a2)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
x = 0
loop1 = n//b + 2
if loop1 > 10**5:
    loop1 = 10**5
    
loop2 = n//a + 2
if loop2 > 10**5:
    loop2 = 10**5

max_ = 0
    
if n < 10**5:
    for x in range(1, n + 1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

else:
    for x in range(1, 10**5):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
    
    for x in range(n - 10**5, n):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
            
    for i in range(1, loop1):
        x = i*b - 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

    for i in range(1,loop2):
        x = i*a + 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        print((a*x)//b,a*(x//b), tmp)
        if tmp > max_:
            max_ = tmp
    
print(max_)

Submission status: Wrong Answer

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

if B <= N:
    x = B - 1
    ans = (A*x)//B-A*(x//B)
if B > N:
    for x in range(1, B):
        if A*x % B == B-1:
            ans = (A*x)//B-A*(x//B)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ab = a/b
maxi = 0
st = max(0, n-a-1)
for x in range(st, n+1):
    z = 0
    if x < b:
        z = math.floor(ab * x)
    else:
        z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

print(maxi)

Submission status: Wrong Answer

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

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

print(calc(B-1))

Submission status: Wrong Answer

Solution code:
import math

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

max_v = 0
for i in reversed(range(1, N + 1)):
    current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
    max_v = max(max_v, current_max_v)
    # 循環したらとめる
    if N > 100000000 and i > N/2:
        break
print(max_v)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
a,b,n = MI()
if n >= b:
  print(max(a-1,0))
else:
  print(math.floor(a*n/b)-a*math.floor(n/b))

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

    if A == 1 or B == 1:
        print(0)
    elif B > 1:
        if B < N:
            print(B//A)
        else:
            print(func(N))


if __name__ == "__main__":
    resolve()

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 n<b:
    print(f(n))
else:
    t = n
    u = n - (n%b+1)
    print(max(f(t),f(u)))

Submission status: Wrong Answer

Solution code:
import math

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

temp = -1 * float('inf')
temp2 = -1 * float('inf')

if A > N or B > N:
    temp = math.floor(A*N/B) - A*math.floor(N/B)
elif A < B and B < N:
    temp = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
else:
    x = A - 1
    while x <= N:
        if temp <= math.floor(A*x/B) - A*math.floor(x/B):
            temp = math.floor(A*x/B) - A*math.floor(x/B)
            x += A

print(temp)

Submission status: Wrong Answer

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

def obj_f(x):
    res = int(a*x/b) - a*int(x/b)
    return(res)

x = n/2
prev_x = 0
next_x = n

while True:
    if obj_f(((x + next_x)/2)) >= obj_f(((x + prev_x)/2)):
        prev_x = x
        x = ((x + next_x)/2)
    else:
        next_x = x
        x = ((x + prev_x)/2)
    if x - prev_x < 1 and next_x - x < 1:
        break

import math
print(max([obj_f(math.floor(x)), obj_f(math.ceil(x))]))

Submission status: Wrong Answer

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

import math

x = n
tmp1 = math.floor(a*x/b) - a*math.floor(x/b)
ret = tmp1

if n//b == 0:
    print(tmp1)
else:
    q, _ = divmod(n, b)
    for i in (list(range(q,q-10**4,-1)) + list(range(1,10**4))):
        x = i*b-1
        tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
        ret = max(ret, tmp2)
    print(ret)

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, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

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

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

    # print('ans')
    # print(n, ans)
    print(int(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:
import sys
import math
p = list(map(int, input().split()))
a=p[0]
b=p[1]
n=p[2]
num = - sys.maxsize
for i in range(1,n+1):
    z = math.floor(a*i/b) - a*math.floor(i/b)
    if z > num and z <= n:
        num = z
print(num)

Submission status: Wrong Answer

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

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


for x in n:
    Y = x//B
    answer = int(A*x/B) - A * Y
    flag = answer
    if flag< answer:
        flag = answer
    
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np

ABN=np.array(input().split(" "),dtype=np.int32)
A=ABN[0]
B=ABN[1]
N=ABN[2]

out=1
for x in range(1,N+1):
    calc=int(A*x//B)-A*int(x//B)
    if(calc>out):
        out=calc

print(out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import floor
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append
 
#for x in range(n+1):
#    append(int((a*(x))/b) - a * int(x/b))
#print(max(li))
def f(x):
    return floor((a*(x))/b) - a * floor(x/b) 
li = [f(x) for x in range(n+1)]
print(li)
if max(li) > n:
    print(0)
else:
    print(max(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def calc(A,B,N):
  left = math.floor( (A * N) / B )
  right = math.floor(N / B) * A
  return(left - right)

def func(A,B,N):
  if( N < B ):
    return(calc(A,B,N))

  anslist = []
  while( N >= B):
    anslist.append(calc(A,B,N))
    N -= 1
  return(max(anslist))


inp1 = input()
inp1li = inp1.split()

A = int(inp1li[0])
B = int(inp1li[1])
N = int(inp1li[2])

print(func(A,B,N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
ans = -1000000000000
p = -1000000000000
for i in reversed(range(1, n+1)):
    t = math.floor(a*i/b) - a * math.floor(i/b)
    if ans < t:
        ans = t
    if p > t:
        break
    else:
        p = t

print(ans)

Submission status: Wrong Answer

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

print(max)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

def F(x):
    return (a*x//b)-a*(x//b)

l=0
r=n+1
ans1=0

for i in range(60):
    m=(r+l)//2
    f=F(m)
    f0=F(max(0,m-1))
    f1=F(min(n,m+1))
    A=max([f,f0,f1])
    #print(m,f,ans1)
    if A>ans1:
        ans1=A
        l=m
    else:
        r=m
    
#print(ans1)
#print(F(500))



ans2=0
if n<=10**6:
    for i in range(n+1):
        f=F(i)
        if f>ans2:
            ans2=f
        #print(i,ans)
#print(ans2)
    print(ans2)
else:
    print(ans1)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map( int, input().split() )
 
def func( x ):
  return math.floor( A * x / B ) - A * math.floor( x / B )
  
ret = 0
min_num = 1
max_num = N
while True:
  a = ( max_num + min_num ) / 2
  if func( max_num ) - func( min_num ) >= 0:
    min_num = a
  else:
    max_num = a
  if func( a ) <= ret:
    break
  ret = func( a )
  
print( ret )

Submission status: Wrong Answer

Solution code:
import math


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

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

    B_A = 1.0 * B / A

    max_value = -1
    for i in range(1, int(min(N + 1, B + 1) / B_A)+1):
        x = B_A * i
        if x > N:
            continue
        v = target(x)
        # print(f'x={i} f(x)={v}')
        if v > max_value:
            max_value = v
    print(max_value)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    A, B, N = map(int, input().split())
    ans = 0
    for i in range(1, min(N + 1, A + 1)):
        ans = max(ans, (A*i)//B - A * (i//B))
        #print(ans, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys

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

result = 0
base_num = 0

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

base_num = 1
for x in range(0, n+1, b):
    result_child = math.floor((a*x)/b) - a * base_num
    if result_child > result:
        result = result_child
    base_num += 1
        
result_child = math.floor((a*n)/b) - a * math.floor(n/b)
if result_child > result:
    result = result_child   
print(result)

Submission status: Wrong Answer

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

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

high = N
low = 0
while high - low > 0.00001:
    mid_left = high / 3 + low * 2 / 3
    mid_right = high * 2 / 3 + low / 3
    # print(mid_left, mid_right)
    if f(mid_left) >= f(mid_right):
        high = mid_right
    else:
        low = mid_left
print(int(f(high)))

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))
elif(n==b or n%b==0):
  print(floor((a*(n-1))/b))
else:
  for i in range(1,(n%b)+1):
    print(floor((a*(n-2-i))/b)-(a*floor((n-2-i)/b)))

Submission status: Wrong Answer

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

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

ans = function(1)
for i in range(1, max(1, (n + 1) // b)):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(max(ans, function(n)))

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    print(math.floor(A*N/B))
else:
    y = N-1
    p = N // B
    x = p*B - 1
    print(max(math.floor(A*y/B) - math.floor(y/B)*A,max(math.floor(A*x/B) - math.floor(x/B)*A, math.floor(A*N/B) - math.floor(N/B)*A)))

Submission status: Wrong Answer

Solution code:
import math
A,B,n=map(int,input().split())
sum=0
x=n
while x!=0:
	ans=math.floor(A*x/B)-A*math.floor(x/B)
	if sum<=ans:
		sum=ans
	else:
		break
	x-=1
print(sum,end="")

Submission status: Wrong Answer

Solution code:
def main():
  import math
  A, B, N = map(int, input().split())
  p = 0
  tobi = B / A
  
  y_0 = math.ceil(tobi * ((int(N / tobi) //2 )+1))
  y_1 = math.ceil(tobi * ((int(N / tobi) //2 )+2))
  y_2 = math.ceil(tobi * ((int(N / tobi) //2 )+3))
  start_0 = ((A * y_0) // B) -  (A *(y_0 // B))
  start_1 = ((A * y_1) // B) -  (A *(y_1 // B))
  start_2 = ((A * y_2) // B) -  (A *(y_1 // B))
  
  if start_2 > start_1: 
    for i in range((int(N / tobi) //2 )+2,int(N / tobi)):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score

  else:
    for i in range(0 ,(int(N / tobi) //2 )+3, -1):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score
     
  print(p)
 
main()

Submission status: Wrong Answer

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

from decimal import *

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

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

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

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

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

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

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

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

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

inf = float('inf')
mod = 1000000007

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

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

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

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

	print(maxs)



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

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

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

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


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

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

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

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

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

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
score1 = math.floor(a*n/b) - a * math.floor(n/b)
x = math.floor(math.floor(n/b)-1*(10**(-13)))
score2 = math.floor(a*x/b) - a * math.floor(x/b)
ans = max(score1, score2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

m = b/a


if b <= n:
    print(math.floor(a*(b-m/2)/b) - a*math.floor((b-m/2)/b))
else:
    print(math.floor(a*n/b) - a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    a, b, n = map(int, input().split())
    # a, b, n = 10 ** 6, 10**6, 10 ** 12
    if n < b:
        if a * n < b:
            print(0)
        else:
            print(math.floor(a * n / b))
    else:
        print(max(math.floor(a*n/b)-a*(math.floor(n/b)),
                  math.floor(a*(n-1)/b)-a*(math.floor((n-1)/b))))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal
a,b,n = map(int,input().split())
ans = 0
al = []
    
for i in range(n,-1,-1):
    t = Decimal(str(a))*Decimal(str(i))//Decimal(str(b))
    t2 = Decimal(str(a))*(Decimal(str(i))//Decimal(str(b)))
    ans = t-t2
    al.append(ans)
    if len(al) > 2:
        if al[-1] <= al[-3]:
            break
            
if max(al) < 0:
    print(0)
else:
    print(max(al))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
#1 <= x <= n
#minimize  int(x/b)
#x = int(a*x/b) - a * int(x/b)
k = n%b
#def func(arr):
  #changed_array = int(a*arr/b) - a * int(arr/b)
  #return changed_array 
  
if n <= b:
  print(int(a*n/b) - a * int(n/b))
else:
  x = n-k-1
  p = int(a*x/b) - a * int(x/b)
  q = int(a*n/b) - a * int(n/b)
  print(max(p,q))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n >= 10**6:
    for x in range(1, n, -10):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**7:
    for x in range(1, n, -100):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**8:
    for x in range(1, n, -1000):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**9:
    for x in range(1, n, -10000):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**10:
    for x in range(1, n, -100000):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**11:
    for x in range(1, n, -1000000):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
elif n >= 10**12:
    for x in range(1, n, -10000000):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
else:
    for x in range(1, n):
        tmp = math.floor(a * x / b) - a * math.floor(x / b)
        ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

#import math
t1 = 0
t2 = 0

f_tmp=0
f_max=0

if(n > b):
    x = b-1
else:
    x = n

#while x < n+1:
t1 = (a*x) // b#math.floor(a*x/b)
t2 = a*(x//b) #a*math.floor(x/b)
#    f_tmp = t1- t2
#    if(f_max < f_tmp):
#        f_max = f_tmp
#    x += 1

print(t1 - t2)

Submission status: Wrong Answer

Solution code:
from math import floor 
a,b,n=map(int,input().split())
ans=0
for x in range(n,-1,-1):
    an=(floor(a*x/b))-a*floor(x/b)
    if an>ans:
        ans=an
    if ans-an>2:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

max_v = 0
for i in reversed(range(1, N + 1)):
    current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
    max_v = max(max_v, current_max_v)
    # 循環したらとめる
    if N > 100 and i > N/2:
        break
print(max_v)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
a,b,n = map(int, input().split())

def num(x):
    return (a*x)//b - a*(x//b)

ma = num(1)

for i in range(2, n+1):
    if num(i) > ma:
        ma = num(i)
    else:
        if num(i) >= num(i-1):
            print(ma)
            exit()
print(ma)

Submission status: Wrong Answer

Solution code:
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,min(a+1,n+1)):
        left = int(a*x*1000000000000000/b/1000000000000000)
        right = a * int(x*1000000000000000/b/1000000000000000)
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

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

F = -1
for x in range(N, 1, -1):
    f = (A * x // B) % A
    if f < F:
        break
    F = f
print(F)

Submission status: Wrong Answer

Solution code:
import math

def calc(A,B,N):
  left = math.floor( (A * N) / B )
  right = math.floor(N / B) * A
  return(left - right)

def func(A,B,N):
  if( N < B ):
    return(calc(A,B,N))

  anslist = []
  NK = N
  while( NK >= B):
    anslist.append(calc(A,B,NK))
    NK -= 1
  return(max(anslist))


inp1 = input()
inp1li = inp1.split()

A = int(inp1li[0])
B = int(inp1li[1])
N = int(inp1li[2])

print(math.floor(9999/10000))
print(func(A,B,N))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=10**6+1:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans
  print("a")
else:
  for i in range(N-10**6,N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans
  print("b")
print(N)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
S =  list(map(int,input().split()))
A = S[0]
B = S[1]
N = S[2]
d = []
from scipy import integrate

# 関数を定義
y = lambda x: A*x/B

# yを0からpiまで数値積分
for i in range(1,N+1): 
    iy,err = integrate.quad(y, i-1, i)
    d.append(math.floor(iy))
    if N+1>B:
        break
print(max(d))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0
h_count = 0

for x in range(1, A[2]+1):
  if i_max <= ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    i_max = ((A[0]*x)//A[1]-A[0]*(x//A[1]))
    i_count = x
  if (i_count != 0) and (i_count != x):
    break
    
print(i_count)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

x = 0
step = int(b/a)
if step == 0 :
    step = 1
while x <= n:
    ans1 = int(a*x/b) + a*int(x/b)
    ans2 = int(a*(a+1)/b) + a*int((x+1/b))
    if ans2 - ans1 >= 0 :
        x += step
    else:
        break
if  n == (x-1) :
    x -= 1
print(int(a*x/b) - a*int(x/b))