Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if b > n:
    print(func(n))
else:
    c = (n//b) -1
    d = b-1
    print(func(b*c + d))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
max = 0
x = 0
n = int(B/A)
if(n < 1):n=1
if(A == 1 or B == 1):
  print(max)
else:
  while(x <= N):
    f = int(A*x/B) - A*int(x/B)
    x += n
    #x += 1
    #print(f)
    if(max <= f):
      max = f
    if(max != 0 and f == 0):
      break
  print(max)

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
    
    z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

# for x in range(0, a):
#     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:
a, b, n = [int(i) for i in input().split()]
m = n % b if n >= b else n

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

Submission status: Wrong Answer

Solution code:
import math

def main():
  a, b, n = map(int,input().split())
  mod = min((n // b) * b - 1,n)
  ans = math.floor(a * mod / b) - a * math.floor(mod / b)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys
import math

sys.setrecursionlimit(10 ** 6)

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


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


def trisect(func):
    left = 1
    right = n
    while abs(right - left) > 0.001:
        d = right - left
        mid_left = left + d / 3
        mid_right = right - d / 3
        if func(mid_left) < func(mid_right):
            left = mid_left
        else:
            right = mid_right
    return left


x = trisect(func)
# print(x)
print(max(func(math.floor(x)), func(math.ceil(x)), func(1), func(n)))

Submission status: Wrong Answer

Solution code:
import math

# 入力
a, b, n = (int(each) for each in input().split())

l = []
if b == 1:
    print(math.floor((a*n)) - a*math.floor(n))
else:
    for x in range((n+1)//b+1):
        x2 = x*b-1
        result = math.floor((a*x2)/b) - a*math.floor(x2/b)
        l.append(result)
        x3 = x*b
        result = math.floor((a*x3)/b) - a*math.floor(x3/b)
        l.append(result)
        # print(result)

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

Submission status: Wrong Answer

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
if (n >= b) and (n % b == 0):
    aa = math.floor(a * (b - 1) / b) - a * math.floor((b -1) / b)
    bb = math.floor(a * (n - 1) / b) - a * math.floor((n - 1) / b)
    print(max(aa, bb))
else:
    print(math.floor(a * n / b) - a * math.floor(n / b))

Submission status: Wrong Answer

Solution code:
a, b , n= input().split() 
a = int(a)
b = int(b)
n = int(n)
if b ==1 and n ==1:
    print((a*n//b) -a)
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:
A,B,N = list(map(int, input().split()))
maxlist = []

def func(A, B, x):
  return (A*x)//B - A * (x//B)

if(N<10**8):
  for i in range(N+1)[::-1]:
    maxlist.append(func(A,B,i))
else:#N>10**8
  for i in range(N-10**6-10**6-10**6,N+1)[::-1]:
    maxlist.append(func(A,B,i))
  
print(max(maxlist))

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()

    p = b-1 if b-1 <= n else n-1
    #print(p)
    print(floor(a*p/b) - a*floor(p/b))


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pprint import pprint as pp
from pprint import pformat as pf

import math


if __name__ == '__main__':
    a, b, n = map(int, input().split())
    if b > n:
        print(n)
    else:
        k = n // b
        print(b * k - 1)

Submission status: Wrong Answer

Solution code:
import math
import sys
#a,b,n
a,b,n = (int(x) for x in input().split())

wk_n = n
wk_xxx = 0
wk_x = 0
cnt=0

while wk_n >= 1 and cnt <= 3000000:
#    print(a,b,n,wk_n,wk_x,wk_n/b - math.floor(wk_n/b))
    if wk_n/b - math.floor(wk_n/b)  >= wk_xxx :
        wk_xxx = wk_n/b - math.floor(wk_n/b)
        wk_x = wk_n
    wk_n-=1
    cnt+=1

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

Submission status: Wrong Answer

Solution code:

A , B , N = list(map(int,input().split()))
S=list()
T=list()
for i in range(0,N+1):
  a= (A*i/B)
  if a >=0:
    a=a//1
    S.append(a)
  if a<0:
    a=(a//1)-1
    S.append(a)

for i in range(0,N+1):
  b= (i/B)
  if b>=0:
    b=b//1
    T.append(b)
  if b<0:
    b=(b//1)-1
    T.append(b)


M=(max(S)-A*min(T))
print(M//1)

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*b//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:
# -*- 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
		#print(maxs)
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 12000000
	for x in range(A,0,-1):
		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 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)):
        temp1 = a * x * 1000000000000000
        temp1 = temp1 // b
        temp1 = temp1 // 1000000000000000
        left = temp1
        temp2 = x * 1000000000000000
        temp2 = temp2 // b
        right = a * temp2
        #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:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 22:26:54 2020

@author: Kanaru Sato
"""

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

def floorspecial(x):
    u = int((a*x)/b)
    v = a*int(x/b)
    print(int(u-v))

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

Submission status: Wrong Answer

Solution code:
import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
bef=-100
count=0
for i in range(1,n+1):
    num=calc(i)
    if num==0:
        if bef!=0:
            if count==0:
                count+=1
            else:
                break
    bef=num
print(bef)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N >= 100000:
    for i in range(N-100,N+1): 
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
else:
    for i in range(N//2,N+1):
        k = (A*i)//B - A*(i//B)
        ans.append(k)
        i = i + 1
    
print(max(ans))

Submission status: Wrong Answer

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)

if N > 10000000:
    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),f(B-2),f(B-3),f(B-4))

    print(ans)

else:
    temp = 0
    for i in range(N+1):
        temp = max(temp,f(i))
    print(temp)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
X=[]
for x in range(10000):
    X.append(abs(math.floor(A*x/B)-A*math.floor(x/B)))
print(max(X))

Submission status: Wrong Answer

Solution code:

from math import floor, ceil, sqrt, factorial, gcd
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
            l=1
            while yd+yd_b < 1:
                yd = ((x+l)/b)-floor((x+l)/b)
                if yd > mx:
                    mx = yd
                l+=1
                yd_b = yd
            yd_b = yd
    else:
        mx = n
    ans = floor(a*mx/b)-a*floor(mx/b)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
ans = -1
for t in range(N):
    x = N-t
    ansX = A*x//B-A*(x//B)
    if ansX > ans:
        ans = ansX
    elif ansX == ans:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
maxi = min(A,N)
ans = 0
for i in range(1,maxi+1):
    ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
if A<N:
    for i in range(B-A,B+1):
        ans = max(ans,math.floor((A*i)/B)-A*math.floor(i/B))
print(ans)

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

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:
#!/usr/bin/env python3
import sys
import numpy as np

def solve(A: int, B: int, N: int):
    ans = 0
    print(A*N//B-A*(N//B))
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def binary_search():
    low = 1
    high = n

    m = -99999999999999

    while low <= high:
        mid = (low + high) // 2

        l = int(a*low/b) - a * (int(low/b))
        h = int(a*high/b) - a * (int(high/b))

        m = max(m, h, l)

        if h > l:
            high = mid - 1
        else:
            low = mid + 1

    l = int(a*low/b) - a * (int(low/b))
    h = int(a*high/b) - a * (int(high/b))

    m = max(m, h, l)

    return m


print(binary_search())

Submission status: Wrong Answer

Solution code:
import math
A, B, N = (int(i) for i in input().split())  
ans = 0
for x in range(0, A+10):
  result = math.floor(A * x / B) - A * math.floor(x/B)
  ans = max(ans, result)
    
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = map(int, input().split())
r = floor(n / b)
x = max(r * b - 1, 0)
max_x = floor(a * n / b) - a * floor(n / b)
for i in range(100000):
    if x > 0:
        max_x = max(max_x, floor(a * x / b) - a * floor(x / b))
        x -= b
    else:
        break
print(max_x)

Submission status: Wrong Answer

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

for x in range(n-1000,n+1):
  li.append(floor(a*x/b)-a*floor(x/b))

print(max(li))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

A, B , N=  [int(i) for i in input().split()]

#if A > B:

N  = int(int(A*N/B)*B/A)+1

print(max(int(A*N/B) - A*int(N/B),0))

Submission status: Wrong Answer

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

fs = []
for x in range(N, max(N - B, 0), -1):
    fs.append( (A * x // B) % A)
    if len(fs) >= 2 and fs[-1] < fs[-2]:
        break
print(max(fs))

Submission status: Wrong Answer

Solution code:
import math

i = 0
lst = []
A, B, N = map(int,input().split())
while(i < N + 1):
    res = math.floor((A*i)/B) - A * math.floor(4/B)
    lst.append(res)
    i += 1

print(max(lst))

Submission status: Wrong Answer

Solution code:
A, B, N = [int(x) for x in input().split()]
max_val = 0
i = B-1
for j in range(min(i,N)):
  x = (A*j)//B - A*(j//B)
  if x > max_val:
    max_val = x

while i<=N:
  x = (A*i)//B - A*(i//B)
  if x > max_val:
    max_val = x
  i+=B
print(max_val)

Submission status: Wrong Answer

Solution code:
import math

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

b=0

if N>B:
  b=B-1
else:
  b=N

c=math.floor(A*b/B)-A*math.floor(b/B)
print(c)

Submission status: Wrong Answer

Solution code:
from math import floor

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

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)
if n<b:
    ans =f(n)
else:
    t = n
    u = n - (n%b+1)
    ans=max(f(t),f(u))
for i in range(max(0,n-1000),n+1):
    ans=max(f(i),ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

from decimal import *

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

nextN = N / 2
r = N / 2

n1 = Decimal(nextN - r / 2)
n2 = Decimal(nextN)
n3 = Decimal(nextN + r / 2)

while r > 100:

    c1 = (A * n1 // B) - (A * (n1 // B))
    c2 = (A * n2 // B) - (A * (n2 // B))
    c3 = (A * n3 // B) - (A * (n3 // B))
    m = max([c1, c2, c3])
    if m == c1:
        nextN = int(n1)
    elif m == c2:
        nextN = int(n1)
    else:
        nextN = int(n1)

    r /= 2

    n1 = Decimal(nextN - r / 2)
    n2 = Decimal(nextN)
    n3 = Decimal(nextN + r / 2)

n1 -= 200
n3 += 200
if int(n1) <= 0:
    n1 = 1
if int(n3) > N:
    n3 = N

m = 0

for x in range(int(n1), int(n3)+1):
    c = (A * x // B) - (A * (x // B))
    if c > m:
        m = c

print(m)

Submission status: Wrong Answer

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

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)

if a2 == 0:
  print(a1)
else:
    x = int(a1*n/a2)
    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(true_x)
    print(a1 if (true_x != -1 and true_x<n) else a2)

Submission status: Wrong Answer

Solution code:
import sys
import math
from pprint import pprint

A, B, N = map(int, sys.stdin.readline().strip().split())

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


right = N
left = 0
while right - left > 5:
    mid_left = right//3+left*2//3
    mid_right = right*2//3+left//3
    # print("mid", mid_left, mid_right)
    #if mid_left == mid_right:
    #    break
    # print("func", func(mid_left), func(mid_right))
    if func(mid_left) < func(mid_right):
        left = mid_left
    else:
        right = mid_right
    # print("lr", left, right)

ans = -1 * float("inf")
for i in range(left, right+1):
    # print(i, func(i))
    ans = max(ans, func(i))
print(ans)

Submission status: Wrong Answer

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

for i in range(n+1-b, n+1):
    num = floor_abx(a, b, i)
    if res < num:
        res = num

print(res)

Submission status: Wrong Answer

Solution code:
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from operator import itemgetter
from collections import defaultdict
import sys
import math
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    a, b, n = wi()
    if b % 2 == 0:
        print((int(a*(b-1)/b) - a*int((b-1)/b))//2)
    else:
        print(int(a*(b-1)/b) - a*int((b-1)/b))
    """
    for i in range(1, b+1):
        print(int(a*i/b) - a*int(i/b))
        c.append(int(a*i/b) - a*int(i/b))
        if i >= b:
            break
    print(max(c))
    """


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


a, b, n = map(int, input().split())
li1 = [0, 1, 2, 3, (n/2-1), n/2, (n/2)+1, n-3, n-2, n-1, n]
li2 = []
for x in li1:
    an = math.floor(a*x/b) - a * math.floor(x/b)
    li2.append(an)
print(max(li2))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
a, b, varConstraint = map(int, input().split())
calculatedNumber = []
for i in range(1, varConstraint + 1):
    calc = ((a * i) // b) - a * (i//b)
    calculatedNumber.append(calc)
print(calculatedNumber[-1])

Submission status: Wrong Answer

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

if b >= n:
    ans = math.floor(a*n/b) - a * math.floor(n/b)
    ans = max(ans, math.floor(a*(n-1)/b) - a * math.floor((n-1)/b))

else:
    ans = 0
    v1 = math.floor(a*n/b) - a * math.floor(n/b)
    v2 = math.floor(a*(n-1)/b) - a * math.floor((n-1)/b)
    v3 = math.floor(a*(n-b-1)/b) - a * math.floor((n-b-1)/b)
    v4 = math.floor(a*(n-b)/b) - a * math.floor((n-b)/b)    
    v5 = math.floor(a*(n-b+1)/b) - a * math.floor((n-b+1)/b)
    ans = max(v1,v2,v3,v4,v5)
#     r = min(n-b, b)
#     for i in range(r + 1):
#         x = n - i
#         v1 = math.floor(a*x/b)
#         v2= a * math.floor(x/b)
#         v =  v1 - v2
#         #print(x, a, x/b, v1, v2, v)
#         ans = max(ans,v)

print(ans)

Submission status: Wrong Answer

Solution code:
def calc(A, B, N):
    for x in range(N, 1, -1):
        if A * x % B != 0 and x % B != 0:
            return int(A * x / B) - A * int(x / B)
    return 0


def main():
    A, B, X = list(map(int, input().split(' ')))
    print(calc(A, B, X))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    print(math.floor(A*N/B))
elif N == B:
    print(0)
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:
def func(a,b,x):
    val = (a*x)//b - a*(x//b)
    return val

a, b, n = map(int, input().split())
if n < b:
    print(func(a,b,n))
else:
    ans = [func(a,b,n)]
    for i in range(n,b-1,-1):
        ans.append(func(a,b,i))
    print(max(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
a,b,n=map(int, input().split())
c = np.array([])
for x in range(n+1) :
     c = np.append(c,int(a*x/b)-a* int(x/b))
print(np.max(c))

Submission status: Wrong Answer

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

def func(A, B, x):
  return (A*x)//B - A * (x//B)

if(N<10**8):
  for i in range(N+1)[::-1]:
    maxlist.append(func(A,B,i))
else:#N>10**8
  for i in range(N-10**6-10**6,N+1)[::-1]:
    maxlist.append(func(A,B,i))
  
print(max(maxlist))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = list(map(int, input().split()))
ans = []
if b < n:
    print(((a * (b-1)) // b - a * ((b-1) // b)))
elif b == n:
    print(0)
else:
    print(a * n // b - a * (n // b))

Submission status: Wrong Answer

Solution code:
import math

def main():
  a, b, n = map(int,input().split())
  mod = max((n // b) * b - 1,n)
  ans = math.floor(a * mod / b) - a * math.floor(mod / b)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
ABN = [int(x) for x in input().split()]
y=[]
if ABN[2]<ABN[1]-1:
  y.append(int(ABN[0]*ABN[2]/float(ABN[1]))-ABN[0]*int(float(ABN[2])/ABN[1]))
else:
  y.append(ABN[0]-int(float(ABN[0])/float(ABN[1])+1))
  if int(ABN[0]*ABN[2]/float(ABN[1]))<=ABN[0]-1:
    a=int(ABN[0]*ABN[2]/float(ABN[1]))
    y.append(a-ABN[0]*int(float(a)/ABN[0]))
  else:
    y.append(ABN[0]-1) 
print(max(y))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B

    for i in range(max(1, N-100000), N + 1):
        ans = max(math.floor(div_ab*i) - A*math.floor(div_1b*i),ans)
    if N > B:
        for j in range(max(int(B)-10000,1), int(B)+1):
            ans = max(math.floor(div_ab * j) - A * math.floor(div_1b * j), ans)

    for k in reversed(range(N-100*B,N+1,B)):
        ans = max(math.floor(div_ab * k) - A * math.floor(div_1b * k), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()