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:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,n = LI()
    if 2*b >= n:
        ans = 0
        for x in range(n-1,0,-b):
            ans = max(ans,(a*x)//b-a*(x//b))
        print(ans)
        return
    ans = 0
    for x in range(max(0,b*((n//b)-1)),n+1):
        ans = max(ans,(a*x)//b-a*(x//b))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
ans=0
p=10**3
if n>=p:
    for i in reversed(range(n-p,n+1)):
        a=math.floor(a*n/b)-a*math.floor(n/b)
        ans=max(ans,a)
else:
    ans=math.floor(a*n/b)-a*math.floor(n/b)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


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


A, B, N = readnums()

'''

x = B - 1のとき最大？
f(A(B - 1) / B) = f(A - A/B)
A*f((B-1)/B) = 0

x = 2B - 1のとき
f(A(2B - 1) / B) = f(2A - A/B)
A*f((2B-1)/B) = A*f(2 - 1/B) = A

A <= Bのとき
x = B - 1のとき最大で、その値はA - 1

A > Bのとき
f(A - A/B) = A - A // B - 1
f(2A - A/B) - A = A - A//B - 1

'''

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

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
list = []

for i in range(N-1,N):
    list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(list[len(list) - 1])

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
ans = 0
if n <= 1000000:
    for i in range(1,n+1):
        k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
else:
    if n <= a or n <= b:
        for i in range(n-10000,n+1):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
    elif a <= b:
        for i in range(max(1,a-10000),min(n+1,a+10000)):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
    elif a > b:
        for i in range(max(1,b-10000),min(n+1,b+10000)):
            k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

pri = math.floor(A * N / B)
lat = A * math.floor(N / B)

max = math.floor(pri - lat)
print(max)

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
a,b,n=map(int,input().split())
if n<=a:
	print((a*n)//b-a*(n//b))
elif n>a and n<b:
	print((a*n)//b-a*(n//b))
else:
	n=b-1
	print((a*n)//b-a*(n//b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 1, -B):
        tmp = (A * i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

A,B,N = LI()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = f(N)
for i in range(10**6+5):
    n = A*i + A-1
    if n > N: break
    ans = max(ans, f(n))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    if maxn < tmp:
        maxn = tmp
    if tmp == 0:
        if sec ==True:
            break
        else:
            sec =True
    
print(maxn)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


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



    l = f(0)
    e = f(N)
    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False

    ok = 0
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok), f(max(0, ok - 1)), f(min(N, ok + 1)))
    for i in range(max(0, ok - 1000), min(N, ok + 1000)):
        ans = max(ans, f(i))

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def calc(a, b, x):
    # print(a, b, x, math.floor(a*x/b), math.floor(x/b))
    return math.floor(a*x/b) - a * math.floor(x/b)
    
ans = -1
for x in range(1, n+1)[::-1]:
    r = calc(a, b, x)
    if r > ans:
        ans = r
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
x = 0
ans1 = 0
while x <= N and x <= A:
    ans = math.floor(A*x/B) - A * math.floor(x / B)
    ans1 = max(ans1, ans)
    x += 1

print(ans1)

Submission status: Wrong Answer

Solution code:
import math
def func(x,a,b):
    return math.floor((a*x)/b)-a*math.floor(x/b)
a,b,n=map(int,input().split())
mx=0
st=b-1
for i in range(st,st+n,b):
    if i>n:
        x=n-1
        xx=func(x,a,b)
        if (xx>mx):
            mx=xx 
    else:
        xx=func(i,a,b)
        if (xx>mx):
            mx=xx 
        
print(mx)

Submission status: Wrong Answer

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

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

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

ans = -1000000
for i in range(l,r+1):
    ans = max(ans,f(i))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


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

result = 0
candidate = -1
for i in reversed(range(0, N+1)):
    if i % B == 0:
        candidate= i-1
        break
if candidate > 0:
    i = candidate
    temp = math.floor(A*i/B) - A*math.floor(i/B)
    result = max(result, temp)

temp = math.floor(A*N/B) - A*math.floor(N/B)
result = max(result, temp)

print(result)

Submission status: Wrong Answer

Solution code:


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

max_ = -A
if A*B > 0:
    for x in range(B):
        num = int((A*x)/B) - A * int(x/B)
        if num > max_:
            max_ = num
else :
    for x in range(B,N+1):
        num = int((A*x)/B) - A * int(x/B)
        if num > max_:
            max_ = num

print(max_)

Submission status: Wrong Answer

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

import numpy as np

ans = -100
for x in range(N+1):
    tmp = np.floor((A*x) / B) - (A * np.floor(x / B))
    if tmp > ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
if B>=N:
    x = N
else:
    x = B-1
max = ((A*x)//B) - A*(x//B)
print(max)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, a+1):
    x = math.ceil(i/(a/b))-1
    if x <= n:
        diff = math.floor(a*x/b) - a*math.floor(x/b)
        ans = max(ans, diff)
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def factor(N):
    ans = []
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

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

if A%B == 0:
    print((B-1)*A//B)
    exit()

b = factor(B-1)
bb = factor(B)
a = factor(A)
aa = factor(A-1)
ans = -1e9
for i in b:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in bb:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in a:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in aa:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
for i in range(int(math.sqrt(B))+2):
    ans = max(ans,math.floor(i*A/B)-A*math.floor(i/B))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0

for i in range(100000*a):
	cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
if A>B:
  print(N)
  exit()
ans =0
for x in range(1,B):
  num = math.floor(A*x/B) - A * math.floor(x/B)
  if num > ans:
    ans = num
print(ans)

Submission status: Wrong Answer

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

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

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

ans = 0

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


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

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

print(solve(m))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

if N // B == 0:
    f, _ = math.modf(N / B)
    ans = math.floor(A * f)
else:
    n = (N // B) * B - 1
    f1, _ = math.modf(n)
    f2, _ = math.modf(N / B)
    f = max(f1, f2)
    ans = math.floor(A * f)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
maxr = 0
minr = 0
ans = 0
if b < n:
    maxr = b + 1
    minr = abs(b - 10) if abs(b - 10) < b else 0
else:
    maxr = n + 1
    minr = abs(n - 10) if abs(n - 10) < n else 0
for i in range(minr, maxr):
    c = math.floor(a * i / b) - math.floor(i / b) * a
    ans = max(ans, c)
print(c)

Submission status: Wrong Answer

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

if a > b:
    print(floor(a,b,n))
else:
    if n < b:
        print(floor(a,b,n))
    else:
        print(floor(a,b,b))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
m = 0
for i in range(1000000):
    if N-i <= 0:
        break
    ans = math.floor((A*(N-i))/B)-A*math.floor((N-i)/B)
    if ans > m:
        m = ans
print(m)

Submission status: Wrong Answer

Solution code:
import math
ans=-100000000
a,b,n=map(int,input().split())
st=1
if n>10000001:
    st=n-a*10
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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()
    maX = 0
    p = b-1 if b-1 <= n else n-1
    maX = floor(a*p//b) - a*floor(p//b)
    for i in range(max(b-30,0),min(n,n+30)):
        maX = max(maX,floor(a*i//b)-a*floor(p//b))
    print(maX)
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
maxn = 0
sec =False
for x in range(1,N+1):
    tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
    print(tmp)
    if maxn < tmp:
        maxn = tmp
    if tmp == 0:
        if sec ==True:
            break
        else:
            sec =True
    
print(maxn)

Submission status: Wrong Answer

Solution code:
import math
A, B, N = list(map(int, input().split(" ")))
res = []

for n,i in enumerate(range(1,N+1)):
  r = math.floor(A*i/B) - A*math.floor(i/B)
  res.append(r)
  if n >= 1:
    if res[n-1] <= res[n]:
      break
print(max(res))

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
x = min(B, N)
floor = lambda A,B,x: (A*x)//B - A*(x//B)
prev = floor(A,B,x)
s = A//B
while True:
    x -= max(s,1)
    c = floor(A,B,x)
    if prev <= c:
        prev = c
    else:
        break
print(prev)

Submission status: Wrong Answer

Solution code:
import math

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

x = 0
answers = []

ryuudo = N / 10

while x <= N:
    answers.append(math.floor(A * x / B) - A * math.floor(x / B))
    x += ryuudo

x = (answers.index(max(answers)) - 2) * ryuudo
stop = (answers.index(max(answers)) + 2) * ryuudo


if x < 0:
    x = 0

answers = []

while x <= stop:
    answers.append(math.floor(A * x / B) - A * math.floor(x / B))
    x += 1

print(max(answers))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
x = 0
m = []
for x in range(1,n+1):
  k = (a*x)//b - a*(x//b)
  print(k)
  m.append(k)

m.sort()

print(m[-1])

Submission status: Wrong Answer

Solution code:
import math
l = input().split()
a = int(l[0])
b = int(l[1])
n = int(l[2])
max = 0
calc = 0
for i in range(1, n+1):
  calc = math.floor(a*i / b) - math.floor(i/b)
  if max < calc:
    max = calc
print(calc)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = 0
tmp = []
idx = 0
for i in range(n, 0, -1):
    k = int(a * i / b) - (a * int(i / b))
    ans = max(ans, k)
    if i == n:
        tmp.append(k)
    else:
        if tmp[idx] == k:
            idx += 1
        else:
            idx = 0
        if idx == len(tmp) - 1:
            break
        tmp.append(k)
print(ans)

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    a,b,n = readInt()
    x = max(n,n//b*(b-1))
    ans = 0
    while x<=n:
        res = a * x // b - a * (x // b)
        ans = max(ans,res)
        x += b-1
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

x = min(b, n)
print(int(a * x / b))

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int,input().split())
if N <= B:
    print(floor(A*N/B)-A*floor(N/B))
else:
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*(B+1)/B)-A*floor((B+1)/B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int,input().split())
m = 0
for i in range(100000):
    if N-i <= 0:
        break
    ans = math.floor((A*(N-i))/B)-A*math.floor((N-i)/B)
    if ans > m:
        m = ans
print(m)

Submission status: Wrong Answer

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

ans = 0
if N == max(A, B, N):
    ans = (A*N//B)-A*(N//B)
else:
    nn = min(N, 10000)
    for x in range(1, nn+1):
        tmp = (A*x//B)-A*(x//B)
        ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a,b,n=n1()

if b<=n:
    i=b
else:
    i=n
m=(a*i)//b-a*(i//b)
print(m)

Submission status: Wrong Answer

Solution code:

a,b,n=map(int,input().split())
print(int(a*n/b)+a*int(n/b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if N >= B:
    print(A-1)
else:
    c = N*A
    if c%B == 0:
        print(c//B-1)
    else:
        print(N*A//B)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(n,n-4,-1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if b > n:
    if b%n !=0:
        ans = math.floor(a*n/b) - a*math.floor(n/b)
    else:
        n -= 1
        ans = math.floor(a*n/b) - a*math.floor(n/b)
    print(ans)
    exit()

M = 0
for i in range(b-1,n,b):
    temp = ans = math.floor(a*n/b) - a*math.floor(n/b)
    M = max(temp,M)

print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

def check(x):
    return int(a*x/b)-a*int(x/b)
    
preans=0
for i in range(n,1,-1):
    ans=check(i)
    if(ans<preans):
        break
    preans=ans
print(preans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
a,b,n=map(int,input().split())

cnt=0

for i in range(a):
	cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cand = []

def calc(n):
  return int(a*n/b)-a*int(n/b)

cand.append(calc(0))
cand.append(calc(n))
cand.append(calc(n-1))
cand.append(max(0, calc(b*(n//b) - 1)))
cand.append(max(0, calc(b*(n//b) - 2)))
cand.append(calc(min(n, b-1)))
cand.append(calc(min(n, b-2)))

print(max(cand))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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)

q, _ = divmod(n, b)
x = q*b-1
tmp2 = math.floor(a*x/b) - a*math.floor(x/b)

print(max(tmp1, tmp2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline

#intの場合
  
A, B ,N  = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

a,b,n = myinput()

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

if n<=b:
    ans = mycalc(a,b,n)
else:
    ans = mycalc(a,b,b-1)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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


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



    l = f(1)
    e = f(N)
    def isOK(mid):
        if f(mid) - l >= 0:
            return True
        else:
            return False

    ok = 1
    ng = N + 1

    loopn = 0

    while abs(ok - ng) > 1:
        loopn += 1
        if loopn >= 10 ** 6:
            break
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    ans = max(l, e, f(ok), f(max(0, ok - 1)), f(min(N, ok + 1)))
    for i in range(max(0, ok - 1000), min(N, ok + 1000)):
        ans = max(ans, f(i))

    print(ans)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

answer = 0

if(A < B):
  cnt = 0
  
  for i in range(1, N+1):
    temp = math.floor((A * i) / B) - (A * math.floor(i / B))
    answer = max(answer, temp)
    
    if temp == 0:
      cnt += 1
    if cnt == 2:
      break
else:
  for i in range(1, N+1):
    temp = math.floor((A * i) / B) - (A * math.floor(i / B))
    answer = max(answer, temp)
    
    if temp == 0:
      break

      
print(answer)

Submission status: Wrong Answer

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

if b>n:
    print((a*n)//b)
else:
    p=-1
    for i in range(n):
        c=(a*(i+1))//b
        d=((i+1)//b)*a
        q=c-d
        if q>p:
            p=q
        if q<=p:
            break

    print(p)

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

# for x in range(1, N+1):
#     res = math.floor(A * x / B) - A * math.floor(x / B)
#     print(res)
#     if res >= m:
#         m = res

x = B - 1
res = math.floor(A * x / B) - A * math.floor(x / B)
print(res)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

a, b, N = map(int,input().split())
ans = 0
for i in range(1,min(N+1,1000000)):
    g = (a*i) // b - a * (i // b)
    #print(g)
    ans = max(ans,g)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
maxr = 0
minr = 0
ans = 0
if b < n:
    maxr = b + 1
    minr = abs(b - 10) if abs(b - 10) < b else 1
else:
    maxr = n + 1
    minr = abs(n - 10) if abs(n - 10) < n else 1
for i in range(minr, maxr):
    c = math.floor(a * i / b) - math.floor(i / b) * a
    ans = max(ans, c)
print(c)

Submission status: Wrong Answer

Solution code:
import sys
a, b, n, = map(int, input().split())
if n < b:
    print(int(a*(n)/b)-a*int((n)/b))
    sys.exit(0)
max = 0
while True:
    if n % b == 0:
        break
    n -= 1
print(int(a*(n-1)/b)-a*int((n-1)/b))

Submission status: Wrong Answer

Solution code:
import math
ans=0
a,b,n=map(int,input().split())
st=1
if n>100000001:
    st=n-a*100
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

def f(n):
    return (a*n)//b-a*(n//b)

ans=0
pre=0
now=x//2
ans=f(now)
i=1
while True:
    i+=1
    if x//(2**i)==0:
        break
    pre_1=f(now-x//(2**i))
    pre_2=f(now+x//(2**i))
    if pre_1<pre_2:
        ans=pre_2
        now=now+x//(2**i)
    else:
        ans=pre_1
        now=now-x//(2**i)


for i in range(now-10**5,now+10**5):
    pre=f(i)
    if ans<pre:
        ans=pre
ans2=ans
ans=0
pre=0
now=x//2
ans=f(now)
i=1
while True:
    i+=1
    if x//(2**i)==0:
        break
    pre_1=f(now-x//(2**i))
    pre_2=f(now+x//(2**i))
    if i==2:
        pre_1,pre_2=pre_2,pre_1
    if pre_1<pre_2:
        ans=pre_2
        now=now+x//(2**i)
    else:
        ans=pre_1
        now=now-x//(2**i)
for i in range(now-10**5,now+10**5):
    pre=f(i)
    if ans<pre:
        ans=pre
        
if ans<ans2:
    ans=ans2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
MOD = 1000000007

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


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

if A == B:
    x = N//A - 1
    print(f(x))


else:
    left = 1
    right = B-1

    left_res = 0
    right_res = 0

    while left != right:
        left_res = f(left)
        right_res = f(right)
        mid = (left + right)//2
        if left_res > right_res:
            right = mid-1
        else:
            left = mid +1

    print(max(f(left_res),f(right_res)))

Submission status: Wrong Answer

Solution code:
#n=int(input())
a,b,n=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(q)]

#for i in range(n+1):
#    print(i,(a*i/b)//1,a*((i/b)//1),(a*i/b)//1-a*((i/b)//1))
print(int((a*(b-1)/b)//1-a*(((b-1)/b)//1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N= map(int, input().split())
ans = 0
c = math.gcd(A,B)
if c != 1:
    A = A//c
    B = B//c
if N>B:
    i = B-1
else:
    i = N
d = (int((A*i)/B) - A *int(i/B))
print(d)

Submission status: Wrong Answer

Solution code:
A,B,N = (int(x) for x in input().split())
x = int(N/2)
ans = -1
length = int(N/4)
while(x > 2):
    ans1 = int(A*x/B) - A*int(x/B)
    ans2 = int(A*(x+1)/B) - A*int((x+1)/B)
    if(x == N):
        if(ans1 > ans):
            ans = ans1
        break
    elif(ans1 > ans2 and ans1 > ans):
        ans = ans1 
        x = ans -length
    elif(ans2 > ans1 and ans2 > ans):
        ans = ans2
        x = ans + length
    else: 
        break
    length = int(length/2)
for i in range(min(6,N)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
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:
import math

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

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

max_k = calc(a,b,n)

for x in range(n,0,-1):
    if x%b==0:
        k = calc(a,b,x-1)
        if max_k < k:
            max_k = k
        break
        
print(max_k)