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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def seq(a, b, x):
    return (a*x)//b - a*(x//b)
def bs(a, b, n):
    low = 0
    high = n
    ans = -1
    while low<=high:
        mid = low + (high-low)//2
        if mid==0 or mid>0 and seq(a, b, mid)>=seq(a, b, mid-1):
            low = mid+1
            ans = mid
        else: high = mid-1
    return ans
a, b, n = map(int, input().split())
print(seq(a, b, bs(a, b, n)))

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
floor = lambda A,B,x: (A*x)//B - A*(x//B)
lb = 0
ub = N
for _ in range(50):
    mid = (lb + ub + 1) // 2
    c = floor(A, B, mid)
    cn = floor(A,B,mid-1)
    if c > cn:
        lb = mid
    else:
        ub = mid
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(n, max(1, n - a - 1), -1):
    ans = max(ans, floor(a * x / b) - a * floor(x / b))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


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


    ans = max(f(1), f(N))
    high = N + 1
    low = 1
    loopn = 0
    while high - low > 1:
        loopn += 1
        if loopn >= 10 ** 5:
            break
        mid_left = int(high / 3 + low * 2 / 3)
        mid_right = int(high * 2 / 3 + low / 3)
        if f(mid_left) >= f(mid_right):
            low = mid_left
        else:
            high = mid_right

    print(max(ans, f(low), f(high)))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
  A, B, N = (int(_) for _ in input().split())
  if N >= (A - 1) * B / A: print(A - 1)
  else:
    print(A * N // B)
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = 0
#hashset = set()
maxNum = -1
while x <= n:
  num = int((a * x / b))
  #hashset.add(num)
  maxNum = max(maxNum, num)
  x += 1

print(int(maxNum))

Submission status: Wrong Answer

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

max = 0

for i in range(min(b, n)):
  x = int((a*i)/b)-a*int(i/b)
  if x > max:
    max = x
  elif max > x:
    break
    
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int,input().split()))
    
a,b,n = readInt()
# print(a,b,n)

f_sum = int(a*n/b) + int(n/b)
print(f_sum)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
width = 10000000
all = []
for x in range(1,min(width,n)):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)

for x in range(n,max(n -width,0) ,-1):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)
print(max(all))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
ans = -int(1e10)
for i in range(min(a+1, n+1)):
    ans = max(ans,(a*i//b)-a*(i//b))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

a,b,n = map(int,input().split())
ans=0
c = 0
e = 0
for i in range(n+1):
  d = 2/b
  if d > e:
    c = i

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
A, B, N = map(int,input().split())

mx = 0

N = min(N,A)

for x in range(1,N+1):
    v = (A*x)//B - A * (x//B)
    #print (v)
    mx = max(mx,v)
print (mx)

Submission status: Wrong Answer

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


c = N // B
d = N % B


ans1 = int(A*N/B) - A * int(N/B)
ans2 = 0

if c != 0:
    N -= d+1
    ans2 = int(A*N/B) - A * int(N/B)

ans = max(ans1, ans2)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
while True:
    if N%B!=0:
        print(math.floor(A*N/B)-(A*math.floor(N/B)))
        break
    else:
        N-=1

Submission status: Wrong Answer

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

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

prev = -1
for n in range(N, 0, -1):
    res = func(n)
    if res < prev:
        print(prev)
        break
    prev = res
else:
    print(prev)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
flg=False
for i in range(N,0,-1):
    t=int(A*i/B)-A*int(i/B)
    ans=max(ans,t)
    if flg:
        break
    if t==0:
        flg=True
print(ans)

Submission status: Wrong Answer

Solution code:
import math


A, B, N = map(int, input().split())
ans = 0
ans_list = []
for i in range(N+1):
  ans = math.floor(A*i/B)-A*math.floor(i/N)
  ans_list.append(ans)
  #print(i,ans)
print(max(ans_list))



#math.floor(

Submission status: Wrong Answer

Solution code:
from math import floor


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


def solve(a, b, n):
    if a == 1 or b == 1:
        return 0
    use = n
    while use % b == 0:
        use -= 1

    return f(a, b, use)


if __name__ == "__main__":
    a, b, n = map(int, input().split())
    print(solve(a, b, n))

Submission status: Wrong Answer

Solution code:
import math
l = []
A,B,x = map(int, input().split())
for i in range(x-1,x+1):
    l.append(math.floor((A*(x))/B)-(A*math.floor((x)/B)))
print(max(l))

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,n=LI()

  right=n
  ans=math.floor(a*right/b)-a*math.floor(right/b)
  left=0
  for _ in range(1000000):
    half=(left+right)//2
    _ans=math.floor(a*half/b)-a*math.floor(half/b)
    if _ans>=ans:
      right=half
      ans=_ans
    else:
      left=half

  return ans

# main()
print(main())

Submission status: Wrong Answer

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

ans = 0
for i in range(n):
  t = int(a * i / b) - a * int(i/b)
  if t > ans:
    ans = t

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
d = N//B
x = d*B
while x < N:
    x += 1


print(int(A*x/B) - A*int(x/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    A,B,N = isRaw()
    if N>=B-1:
        res = ((N+1)//B)*B-1
    else:
        res = N
    return int((A*res)/B)-A*int(res/B)

    
if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C1,C2)
    if C1>C2:
        ed=mid2
    elif C1<C2:
        st=mid1
    elif C0>C3:
        ed=mid2
    else:
        st=mid1
if ed-st==2:
    C=max(main(st),main(st+1),main(ed))
print(C)

Submission status: Wrong Answer

Solution code:
from math import floor
a,b,n = map(int,input().split())
ans = 0
dd = 0
if min(a,b) > n:
    ans = floor(a*n/b) - a*floor(n/b)
    print(ans)
    exit()
else:
    for i in range(min(a,b)):
        y = (floor(a*i/b) - a*floor(i/b))
        if y >= ans:
            dd = 1
            ans = y
        else:
            print(ans)
            exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
import math
ans=0
for i in range(1,a+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=[int(x) for x in input().split()]
print(min(n,b-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for x in range( int( a * n / b ) + 2 ):
    f_x = int( a * x / b ) - a * int( x / b )
    if x == 0 or f_max < f_x:
        f_max = f_x

print( f_max )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,n = m()

if a > b:
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

Submission status: Wrong Answer

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

print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])
max = 0
for x in range(int(N/2), N+1):
    S = int(A * x / B) - A * int(x / B)
    
    if max<S:
        max = S
        print(max)
print(max)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
width = 10000
all = []
for x in range(1,min(width,n)):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)

for x in range(n,max(n -width,0) ,-1):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)
print(max(all))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
max_v = 0
c = max(n, b % a)
for i in range(c+1):
    v = (a * i // b) - a * (i // b)
    max_v = max(max_v, v)
print(max_v)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = 0
for i in ps:
  if N < i: continue
  for j in range(1, 10 ** 6 + 1):
    x = i * j
    res = max(res, (A * x) // B - A * (x // B))
for x in range(1, min(N, 10 ** 6)):
  res = max(res, (A * x) // B - A * (x // B))
print(res)

Submission status: Wrong Answer

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

if N>B:
    x = B -1
else:
    x = N
F1 = (A*x)//B
F2 = A * (x//B)
S = F1 - F2
print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int, N: int):
    def kansuu(x):
        return math.floor(A*x/B) - A * math.floor(x/B)

    saidaibaisuu = (N // B) * B
    if saidaibaisuu == 0:
        print(kansuu(N))
        exit()
    else:
        print(kansuu(saidaibaisuu-1))
        exit()

    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:
a,b,n = map(int,input().split())
width = 100000
all = []
for x in range(1,min(width,n)):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)

for x in range(n,max(n -width,0) ,-1):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)
print(max(all))

Submission status: Wrong Answer

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

ans = 0
for x in range(n, max(0, n - a - 1), -1):
    ans = max(ans, a * x // b - a * (x // b))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N+1):
    if((A*i)/B - A*(i/B) > bst):
        bst = (A*i)/B - A*(i/B)

print(bst)

Submission status: Wrong Answer

Solution code:
import math
l = []
A,B,x = map(int, input().split())
for i in range(1,x+1):
    l.append(math.floor((A*(x))/B)-(A*math.floor((x)/B)))
print(max(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
ans = 0
C = A/B
for x in range(1, min(A, N)+1):
    ans = max(floor(C*x)-A*floor(x/B), ans)
print(ans)

Submission status: Wrong Answer

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

o = x
x = max(0, x - 500000)

m = 0

while x <= o:
    r = max(0, o - x)

    m = max(m, (a*x) // b - a * (x // b))
    m = max(m, (a*r) // b - a * (r // b))
    x += 1

print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
width = 1000
all = []
for x in range(1,min(width,n)):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)

for x in range(n,max(n -width,0) ,-1):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)
print(max(all))

Submission status: Wrong Answer

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

dai = n

shou = 0

while shou+1 != dai:
    mid = (dai+shou)//2
    memo = int(a*mid/b)-a*int(mid/b)
    #ans = max(ans,memo)
    if memo == 0:
        dai = mid
    else:
        shou = mid
        
ans = max(int(a*dai/b)-a*int(dai/b),int(a*shou/b)-a*int(shou/b))
print(ans)

Submission status: Wrong Answer

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

left, right = 0, n + 1
while right - left > 1:
  x = mid = (left + right) // 2
  val = a * x // b - a * (x // b)
  if val > 0:
    left = mid
  else:
    right = mid

print(val)

Submission status: Wrong Answer

Solution code:
from math import floor


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

    if n < b:
        x = n
    else:
        x = b
    ans = floor(a * x/b) - a * floor(x/b)

    print(int(ans))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import floor
a,b,n = map(int,input().split())
ans = 0
dd = 0
if min(a,b) >= n:
    ans = floor(a*n/b) - a*floor(n/b)
    print(ans)
    exit()
else:
    for i in range(min(a,b)):
        y = (floor(a*i/b) - a*floor(i/b))
        if y >= ans:
            dd = 1
            ans = y
        else:
            print(ans)
            exit()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


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


    ans = max(f(1), f(N))
    high = N + 1
    low = 1
    while high - low > 1:
        mid_left = high // 3 + low * 2 // 3
        mid_right = high * 2 // 3 + low // 3
        if f(mid_left) >= f(mid_right):
            low = mid_left
        else:
            high = mid_right

    print(max(ans, f(low), f(high)))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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:
    print(f(n))
elif n==b:
    print(f(n-1))
elif n>b:
    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())

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

Submission status: Wrong Answer

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

lo = 0
hi = N
ans = 0

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

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

print(f(lo))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import random
import copy
import math
def main():
     A,B,N = map(int,input().split())
     x = min(B,N)-0.000000000000001
     ma = math.floor(A*x/B)-A*math.floor(x/B)
     print(ma)
                    
main()

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
MAX = -10**18
if N >= B:
    x = B
else:
    x = N


ans = A*x//B - A*(x//B)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

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


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


print(f(A, B, N))

Submission status: Wrong Answer

Solution code:
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

A,B,N = Ints()

x = min(int(A*N/B),A-1)
print(x - A*int(x/A))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
# a = 99999
# b = 10
# n = 4
# x = 1
all = []
for x in range(1,min(100,n)):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)

for x in range(n,max(n -100,0) ,-1):
    ans = int((a * x) // b)  - a * int(x // b) 
    all.append(ans)
print(max(all))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,n = m()

if a >= b:
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int,input().split()))
    
a,b,n = readInt()
f_max = 0
# print(a,b,n)
for x in range(n+1):
    f_sum = int(a*x/b) + int(x/b)
    # print(f_sum)
    if f_sum>=f_max:
        f_max = f_sum
print(f_max)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = 0
for x in ps:
  if N < x: continue
  res = max(res, (A * x) // B - A * (x // B))
for x in range(1, min(N, 10 ** 6)):
  res = max(res, (A * x) // B - A * (x // B))
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,n=LI()

  right=n
  ans=math.floor(a*right/b)-a*math.floor(right/b)
  left=0
  for _ in range(1000000):
    half=(left+right)//2
    _ans=math.floor(a*half/b)-a*math.floor(half/b)
    if _ans>=ans:
      right=half
      ans=_ans
    else:
      left=half
    if ans==4:
      return [left,half,right]

  return ans

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(min(n+1,a+1)):
    c = int(a*i/b) - a*int(i/b)
    ans = max(c,ans)
    
print(ans)

Submission status: Wrong Answer

Solution code:
[A,B,N] = [int(s) for s in input().rstrip().split(' ')]
if B == 1:
    print(0)
elif N <= B:
    print(A*N//B)
else:
    print((A*(B-1))//B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = a % b / b
ans = int(a*n/b)-a*int(n/b)
for i in range(n-10**6,n)[::-1]:
    tmp = int(a * i / b) - a * int(i / b)
    ans = max(ans, tmp)


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,x = map(int, input().split())
print(math.floor((A*(x))/B)-(A*math.floor((x)/B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

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

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

# print(bisearch(calc, ok, ng))
ans = 0
for i in range(min(N+1, 10)):
    ans = max(calc(i), ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys
sys.setrecursionlimit(10**9)
A,B,N= map(int,input().split())

x = min(N, B-1)

ans = (A*x)//10
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
  a,b,n = map(int,input().split())
  ans = a*n//b
  print(ans)

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,n=LI()

  right=n
  ans=math.floor(a*right/b)-a*math.floor(right/b)
  left=0
  for _ in range(10000):
    half=(left+right)//2
    _ans=math.floor(a*half/b)-a*math.floor(half/b)
    if _ans>=ans:
      right=half
      ans=_ans
    else:
      left=half
    if ans==4:
      return [left,half,right]

  return ans

# main()
print(main())