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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math


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


s = input()
input_arr = s.split()

a = int(input_arr[0])
b = int(input_arr[1])
n = int(input_arr[2])


if b <= n:
    x_max = b
else:
    x_max = n

x_min = b/a
x_min = math.floor(x_min)+1

v = []

for i in range(x_min, x_max):
    v.append(calc(a, b, i+1))

print(max(v))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
A,B,N=map(int,input().split())
s=0
for x in range N:
  p=math.floor(A*x/B)
  q=A*math.floor(x/B)
  r=p-q
  if r>s:
    s=r
print(s)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = int((a * n) / b) - a * int(n / b)
n = n - 1
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 2
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = n - 3
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(x, 1)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(x, 2)
ans = max(ans, int((a * n) / b) - a * int(n / b))
n = min(x, 3)
ans = max(ans, int((a * n) / b) - a * int(n / b))
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    a, b, n = map(int, input().split())
    mx = 0
    yd_b = 1

    if b < n:
        for x in range(b-1, n+1, b):
            yd = (x/b)-floor(x/b)
            if yd > mx:
                mx = yd

            if yd+yd_b < 1:
                yd = (x+1/b)-floor(x+1/b)
                if yd > mx:
                    mx = yd
            yd_b = x
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)

    # li = [(x/b)-floor(x/b) for x in range(1, n+1)]
    # #yd = (x/b)-floor(x/b)
    # x = li.index(max(li))+1
    # ans = floor(a*x/b)-a*floor(x/b)
    # print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
 
if N <B:
	print(math.floor(A*N/B))
	exit()
 
k = [0]*(math.floor(N/B)+1)
 
for i in range (1, math.floor(N/B)+2):
	k[i-1] = i*B-1
 
k[-1] = N
 
p=[0]*len(k)
 
for i in range (0, len(k)):
	p[i] = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
 
print(max(p))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m, q = input().split()
n = int( n )
m = int( m )
q = int( q )
a = []
b = []
c = []
d = []
for i in range( int( q ) ):
    a_i, b_i, c_i, d_i = input().split()
    a.append( int( a_i ) )
    b.append( int( b_i ) )
    c.append( int( c_i ) )
    d.append( int( d_i ) )

array = [ 1 ] * n
array_list = [ array ]

i = 0
while True:
    for k in range( array_list[i][-1], m + 1 ):
        array_list.append( array_list[i][1:] + [ k ] )
        #print( array_list[i][1:] + [ k ] )
    i = i + 1
    if len( array_list ) > 1000:
        break

max_score = 0
for array in array_list:
    score = 0
    for i in range( q ):
        #print( i, a[i], b[i], c[i], array )
        if array[b[i]-1] - array[a[i]-1] == c[i]:
            score = score + d[i]
    if max_score < score:
        max_score = score

print( max_score )

Submission status: Runtime Error

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

t=0
xx=0
l=[-1]*(b+1)
p=1
if n>=b and b>1:
   while t == 0 and xx <= n:
      xx += 1
      c=a*xx%b
      if l[c]==-1:
         l[c]=xx
      else:
         t=1
   while t>-1:

      if l[p]>-1:
         t=-2
         x=l[p]
      p+=1
else:
   x=n
print(a*x//b-a*(x//b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
count = 0
num = int(N / B)
array = list(range(N, B * num,-1))
array.append(i for i in range(B * num, -1, -B))
# print(array
for x in range(N,0,-1):
    if count > 1000000:
        break
    xb = x / B
    if xb < 1 and ans != 0:
        count += 1
#         print("continue")
        continue
    floor = int(A*xb) - A * int(xb)
    if ans < floor:
#         print(x)
#         print(x,count)
        count = 0
        ans = floor
    count += 1
print(ans)

Submission status: Runtime Error

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)
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: Runtime Error

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: Runtime Error

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: Runtime Error

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

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

Submission status: Runtime Error

Solution code:

import numpy as np
import math
a,b,n=map(int,input().split())

x=np.arange(1,math.log10(n),0.01)
s1=np.floor(a*x*10**math.log10(n)/b)
s2=a*np.floor(x*10**math.log10(n)/b)
s=s1-s2

if n<b:s=np.array(math.floor(a*n/b)-a*math.floor(n/b))
print(int(np.max(s)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, M, Q = map(int, input().split())
    r_list = []
    for i in range(Q):
        r_list.append(list(map(int, input().split())))
    max_score = 0
    a1 = 1
    for a2 in range(a1, M+1):
        for a3 in range(a2, M+1):
            for a4 in range(a3, M+1):
                for a5 in range(a4, M+1):
                    for a6 in range(a5, M+1):
                        for a7 in range(a6, M+1):
                            for a8 in range(a7, M+1):
                                for a9 in range(a8, M+1):
                                    for a10 in range(a9, M+1):
                                        a_list = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                                        score = 0
                                        for r in r_list:
                                            if a_list[r[1]-1] - a_list[r[0]-1] == r[2]:
                                                score += r[3]
                                        max_score = max(score, max_score)
    print(max_score)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from math import floor

A, B, N = [int(n) for n in input().split()]
ans = []
for x in range(1, A):
    ans.append(int(floor(A*x/B) - A*floor(x/B)))
print(max(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

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

#s = B if N > B else N
#print(s)

x = np.arange(0, N+1)
x1 = np.floor(A * x / B)
x2 = A * np.floor(x / B)
X =  x1 - x2

print(int(np.max(X)))

Submission status: Runtime Error

Solution code:
import math

a = [int(i) for i in input().split()]

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

result = 0
for i in range(a[2]/2, a[2]+1):
    result = max(result, calc(a[0], a[1], i))

print(result)

Submission status: Runtime Error

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: Runtime Error

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

print(floor(A*(N-1)/B)-A*floor((N-1)/B))

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
 
if N <B:
	print(math.floor(A*N/B))
	exit()
 
k = [0]*(math.floor(N/B)+1)
 
for i in range (1, math.floor(N/B)+2):
	k[i-1] = i*B-1
 
for i in range (0, len(k)):
	if k[i] > N:
		k[i]=0
 
p=[0]*len(k)
 
for i in range (0, len(k)):
	p[i] = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
 
print(max(p))

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
A=0
C=b[1]
max = math.floor(b[2]/b[1])
if max == 0:
    if b[1]-1>0:
        check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
        if check > ans:
            ans=check
else:
    for i in range(max+1):
        A=b[1]-1
        if A>0:
            check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
            if check > ans:
                ans=check
        b[1]+=b[1]
print(ans)

Submission status: Runtime Error

Solution code:
from math import floor, ceil, sqrt, factorial, gcd
def main():
    a, b, n = map(int, input().split())
    mx = 0

    if b < n:
        for x in range(b-1, n+1, b):
            yd = (x/b)-floor(x/b)
            if yd > mx:
                mx = yd
                
            if yd+yd_b<1:
                yd = (x+1/b)-floor(x+1/b)
                if yd > mx:
                mx = yd
            yd_b=x
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
a_list=[]
for x in range(1,b):
    if x>=n:
        break
    a_list.append((math.floor(a*x/b)-a*math.floor(x/b)))
print(max(a_list))

Submission status: Runtime Error

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

import math

cnt = 0
box = [0]
floor = math.floor(a*n/b) - a*math.floor(n/b)
box.append(floor)
for x in reversed(range(1, n+1, int(b/2))):
  floor = math.floor(a*x/b) - a*math.floor(x/b)
  box.append(floor)
  cnt+=1
#  if cnt > b/2+1:
#    break
#  print(x, math.floor(a*x/b), a*math.floor(x/b), floor)

box.sort(reverse=True)
print(box[0])
#print(box)

Submission status: Runtime Error

Solution code:
#n=int(input())
n,m=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(q)]
b=(n-1)//2
a=b//2
ll=[[0,0]for i in range(b)]
ll[0]=[1,2]

if b//2==b/2:
    for i in range(1,b):
        if i//2!=i/2:
            ll[i]=[2+a-(i//2),2+a-(i//2)+i+1]
        else:
            if i==b-2:
                ll[i]=[3+b//2,3+b//2+b-2+1]
            else:
                ll[i]=[3+b//2+b-2+1-i//2,3+b//2+b-2+1-i//2+i+1]
else:
    for i in range(1,b):
        if i//2==i/2:
            ll[i]=[3+b//2-i//2,3+b//2-i//2+i+1]
        else:
            if i==b-2:
                ll[i]=[3+b//2+1,3+b//2+b-1+1]
            else:
                ll[i]=[3+b//2+b-1+1-(i+1)//2,3+b//2+b-1+1-(i+1)//2+i+1]            

for i in range(m):
    print(*ll[i])

Submission status: Runtime Error

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(N//1.2,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: Runtime Error

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

print(floor(A*3/B)-A*floor(3/B))

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
A=0
C=b[1]
max = math.floor(b[2]/b[1])

    for i in range(max):
        A=b[1]-1
        if A>0:
            check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
            if check > ans:
                ans=check
        b[1]+=b[1]
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

tans = 0

if B <= N:
  for i in range(B-1,N+1):
    ans = math.floor(A*i/B) - A*math.floor(i/B)
    print(i,math.floor(A*i/B), math.floor(i/B))
    tans = max(ans,tans)
else:
  tans = math.floor(A*N/B)
  
#for i in range(1,N+1):
#  ans = math.floor(A*i/B) - A*math.floor(i/B)
#  print(i,math.floor(A*i/B), math.floor(i/B))
#  tans = max(ans,tans)

print(tans)

Submission status: Runtime Error

Solution code:
import math

a, b, n = map(int, input().split())
li = []
for x in range(n-1, n+1):
    an = math.floor(a*x/b) - a * math.floor(x/b)
    if an <= n:
        li.append(an)
print(max(li))

Submission status: Runtime Error

Solution code:
from math import floor
 
a, b, n = list(map(int, input().split()))
 
 
def floorMax(nums):
    ans = floor((a * nums)/b) - a * floor(nums/b)
    return ans
 
 
def findPeakUtil(arr, low, high, n):
    mid = low + (high - low)/2
    mid = int(mid)
 
    if ((mid == 0 or floorMax(arr[mid-1]) <= floorMax(arr[mid])) and (mid == n - 1 or floorMax(arr[mid + 1]) <= floorMax(arr[mid]))):
        return mid
    elif (mid > 0 and floorMax(arr[mid - 1]) > floorMax(arr[mid])):
        return findPeakUtil(arr, low, (mid - 1), n)
    else:
        return findPeakUtil(arr, (mid + 1), high, n)
 
 
def findPeak(arr, n):
    return findPeakUtil(arr, 0, n - 1, n)
 
 
index = findPeak(list(range(0, n+1)), n)
 
ans = list(range(n))[index]
 
print(floorMax(ans+1))

Submission status: Runtime Error

Solution code:
import math
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	ax = A * x
	if x >= B:
		t = math.floor(ax / B) - A * math.floor(x / B)
	elif ax >= B and x < B:
		t = math.floor(ax / B)
	elif ax < B:
		continue

	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

s = B if N > B else N
#print(s)

x = np.arange(0, int(s/2))
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])
def fl(x):
    return math.floor((A*x)/B) - A*math.floor(x/B)

An =fl(N)
    
if B < N :
    for i in range(B,N) :
        if i >= B+1 and fl(i) <= fl(i-1) :
            An = fl(i-1)
            break
elif B = N :
    An = fl(N-1)

print(str(An))

Submission status: Runtime Error

Solution code:
import sys
import math

lines = sys.stdin.readlines()

X = lines[0].split(' ')
A = int(X[0])
B = int(X[1])
N = int(X[2])

m = A // B
j = A % B

if N >=B-1:
    print(m*(B-1)-1+j)
else:
    k = B-N
    print(max(0,j+m*N-math.ceil(j*k/B))

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
A=0
C=b[1]
max = math.floor(b[2]/b[1])
if max == 0:
    if b[1]-1>0:
        check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
        if check > ans:
            ans=check
else:
    for i in range(max):
        A=b[1]-1
        if A>0:
            check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
            if check > ans:
                ans=check
        b[1]+=b[1]
print(ans)

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main(void){
    long long int a,b,n;
    scanf("%lld %lld %lld",&a,&b,&n);
    printf("%lld\n",(a*(n-1))/b-a*((n-1)/b));
    return 0;
}

Submission status: Runtime Error

Solution code:
from collections import deque
n,m,q = map(int,input().split())
l = list(list(map(int,input().split())) for _ in range(q))
if m<7:
  num = ["1"*n]
  k = deque(["1"*n])
  while len(k)!=0:
    h = k.popleft()
    if int(h[-1])<m:
      num.append(str(int(h)+1))
      num.append(str(int(h)+11))
      num.append(str(int(h)+111))
      k.append(str(int(h)+1))
      k.append(str(int(h)+11))
      k.append(str(int(h)+111))
  num = list(set(num))
  ma = 0
  for i in num:
    s = 0
    for a,b,c,d in l:
      if int(i[b-1])-int(i[a-1])==c:
        s += d
        ma = max(ma,s)
  print(ma)
else:
  l1 = sorted(l,key=lambda x:x[3])[::-1]
  print(l1[0][-1])

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
# xはN以下
# int(A*x/B) - A*int(x/B)の最大値を求めたい


compute_range = list(range(0, math.ceil(N / B) + 1))
# print(compute_range)


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


if N > B:
    max_num = h((compute_range[-2]) * B - 1)
else:
    max_num = h(N)

print(max_num)

Submission status: Runtime Error

Solution code:
from math import gcd
A,B,N = list(map(int,input().split()))
ans = 0
lcm = A*B//gcd(A,B)
if N < 2*10**6:
    for x in range(N+1):
        ans = max(ans,(A*x//B)-A*(x//B))
else:
    for x in range(10**6+2):
        ans = max(ans,(A*x//B)-A*(x//B))
    for x in range(N,N-10**6,-1):
        ans = max(ans,(A*x//B)-A*(x//B))
    if lcm <= N:
        ans = max(ans,(A*(lcm-1)//B)-A*((lcm-1)//B))
        tmp = (N//lcm)*lcm
        ans = max(ans,(A*(tmp-1)//B)-A*((tmp-1)//B))
    for x in range(B-1,(B-1)+100):
        ans = max(ans,(A*x//B)-A*(x//B))
    ans = max(ans,(A*(tmp-1)//B)-A*((N//B * B-1)//B))

print(ans)

Submission status: Runtime Error

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

for x in range(min(x,B)):
    y = math.floor((A*x)/B) - A*math.floor(x/B)
    if(max<y):
        max = y
    
while(B*n <= N):
    x = B*n -1
    y = math.floor((A*x)/B) - A*math.floor(x/B)
    if(max<y):
        max = y
    n += 1

print(max)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

def f(x):
    f = np.max(math.floor(A*x/B)-A*math.floor(x/B))    

A, B, N = map(int,input().split())
l=[]
for x in range(N+1):
    l.append(f)
    
print(max(l))

Submission status: Runtime Error

Solution code:
from math import floor

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


def floorMax(nums):
    ans = floor((a * nums)/b) - a * floor(nums/b)
    return ans


def findPeakUtil(arr, low, high, n):
    mid = low + (high - low)/2
    mid = int(mid)

    if ((mid == 0 or floorMax(arr[mid-1]) <= floorMax(arr[mid])) and (mid == n - 1 or floorMax(arr[mid + 1]) <= floorMax(arr[mid]))):
        return mid
    elif (mid > 0 and floorMax(arr[mid - 1]) > floorMax(arr[mid])):
        return findPeakUtil(arr, low, (mid - 1), n)
    else:
        return findPeakUtil(arr, (mid + 1), high, n)


def findPeak(arr, n):
    return findPeakUtil(arr, 0, n - 1, n)


index = findPeak(list(range(0, n+1)), n)

ans = list(range(n))[index]

print(floorMax(ans+1))

Submission status: Runtime Error

Solution code:
import numpy as np
A, B, N = map(int, input().split())
max_val = -1000000000000000000
max_x = 0
for i in range(N+1):
    y = np.floor(A/B*i) - A*np.floor(x/B)
    if max_val < y:
        max_val = y
        max_x = i
print(x)

Submission status: Runtime Error

Solution code:
from collections import deque
a,b,c=[int(_) for _ in input().split()]
k=c-1
s=math.floor((k*a)/b)-a*math.floor(k/b)
t=math.floor((c*a)/b)-a*math.floor(c/b)
if b<c:
    l=b-1
    g=b
    v=math.floor((l*a)/b)-a*math.floor(l/b)
    m=math.floor((g*a)/b)-a*math.floor(g/b)
    print(s,t,m,v)
else:
    print(max(s,t))

Submission status: Runtime Error

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

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

print(result)

Submission status: Runtime Error

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

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

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

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

        while right-left > 1:
            x = (right+left) // 2
            # print(left,right)
            if f(x) < a:
                left = x
            else:
                right = x

        # print("____")
        # print(right)
        return right


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


if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
if N < B:
    print(A*N//B)
else:
    l = [(A*i//B)-(A*(i//B)) for i in range(abs(N-5), N+1)]
    print(max(l))

Submission status: Runtime Error

Solution code:
import math
A,B,N = map(int, input().split())  
ANS=[0]*(N)
k=1
for i in range(N):
  if B<k:
    break
  ANS[i]=math.floor(A*k/B)-(A*math.floor(k/B))
  k+=1
ANS.sort()
print(ANS[-1])

Submission status: Runtime Error

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

for x in range(min(x,B)):
    y = math.floor((A*x)/B) - A*math.floor(x/B)
    if(max<y):
        max = y
    
while(B*n <= N):
    x = B*n -1
    y = math.floor((A*x)/B) - A*math.floor(x/B)
    if(max<y):
        max = y
    n += 1

print(max)

Submission status: Runtime Error

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

print(N//abs(A-B))

Submission status: Runtime Error

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

for x in range(B):
    ls.append(int(A*x/B)-A*(int(x/B)))
result=max(ls)
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
x = np.arange(min(N, B-1), N+1, B, dtype="float32")
x = func(x)

# 結果出力
print(int(np.max(x)))

Submission status: Runtime Error

Solution code:
import numpy as np

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

s = B if N > B else N
#print(s)

x = np.arange(0, s+1)
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Submission status: Runtime Error

Solution code:
s = raw_input()
a, b, n = s.split()
a = int(a)
b = int(b)
n = int(n)

from math import floor

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

Submission status: Runtime Error

Solution code:
#include<stdio.h>
#include<math.h>
void main(){
	int a,b,n,temp,i,arr[100];
	scanf("%d%d%d",&a,&b,&n);
	for(i=0;i<=n;i++)
	{
		arr[i]=floor((a*i)/b)-(a*(floor(i/b)));
	}
	for(i=0;i<=n;i++)
	{
		if(arr[0]<arr[i])
		{
			temp=arr[0];
			arr[0]=arr[i];
			arr[i]=temp;
		}
	}
	printf("%d",arr[0]);

}

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
max = 0
wait = int((B/A) + 1)
for x in range(1, N+1, wait-1):
    fun = int(A*x/B) - A*int(x/B)
    if x == 1:
        x0 = fun
    elif x > wait:
        if x0 == fun:
            break
    if max < fun:
        max = fun
print(max)

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
max = b[2]//b[1]
if max <=0:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
    ans = 0
    if check > ans:
        ans=check
else:
    for i in range(max):
        A=b[1]-1
        if A>0:
            check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
            if check > ans:
                ans = check
        b[1]+=b[1]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = floor(A*3/B)-A*floor(3/B)
print(a)

Submission status: Runtime Error

Solution code:
import math

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

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

print(max)

Submission status: Runtime Error

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

lo = 1
hi = N

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

ans = 0
if B-1<=N:
    ans = f(B-1)

while hi > lo :
    if f(lo) <= f(hi):
        mid = (lo + hi) // 2
        if f(mid)<=f(mid+1):
            lo = mid+1
        else:
            lo = mid
    else:
        mid = -(-(lo + hi) // 2)
        hi = mid

ans = max(ans,f(lo),f(N-1),f(B*N//B-1)+1

print(ans)

Submission status: Runtime Error

Solution code:
A, B, N = map(int,input().split())
if(B-A < N) :
 cal = int((A*N)/B) - A*int(N/B)
 print(cal)
else 
 max = 0
i=N
while(1):
 cal = int((A*i)/B) - A*int(i/B)
 if(cal > max):
  max =cal
 i += -1
 if(i < 0):
  print(max)
  break;

Submission status: Runtime Error

Solution code:

A, B, N=list(map(int, input().split()))
if B > N:
    X = N
else:
    X = B-1

Ans = math.floor(A*X/B) - A * math.floor(X/B)
print(Ans)

Submission status: Runtime Error

Solution code:
import math

A, B, N= (int(x) for x in input().split())
#x = B * math.floor(N/B) - 1
x =  B - 1
if N < B
    x = N
a = math.floor(A * x / B) - A * math.floor(x / B)
b = math.floor(A * N / B) - A * math.floor(N / B)

if a > b:
    print(a)
else:
    print(b)

Submission status: Runtime Error

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