Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

import math

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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

max_score = 0

x = N
# while B > x > 0:
score = math.floor(A * x / B) - A * math.floor(x / B)
# max_score = max(score, max_score)
    # x -= 1

# +print(max_score)
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

temp = -1 * float('inf')

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

print(temp)

Submission status: Wrong Answer

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

ans = 0;
new_ans = 0;

for x in range(n):
  new_ans = int(a * x / b) - a * (int(x / b))
  if ans > new_ans:
    break
  else:
    ans = new_ans;
    
print(ans)

Submission status: Wrong Answer

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



def bs(l,c,r):
  global a,b

  #print(l,c,r)

  if l>=r:
    print(int(a*c/b)-a*int(c/b))
    return

  w1=int(a*(c-1)/b)-a*int((c-1)/b)

  w=int(a*c/b)-a*int(c/b)

  w2=int(a*(c+1)/b)-a*int((c+1)/b)

  #print("w",w1,w,w2)

  if (r-l)<3:
    if w1<w2:
      print(w2)
      return 
    else:
      print(w1)
      return 

  elif w1>w and w>w2:
    bs(l,int((l+c)/2),c)

  elif w1<w and w<w2:
    bs(c,int((r+c)/2),r)

  elif w1==w or w==w2:
    print(w)
    return

  return 0

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

bs(0,int(n/2),n)

Submission status: Wrong Answer

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

ans = 0
for x in range(1, n + 1):
    if x > b:
        continue
    ans = max(ans, a*x // b)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

temp_prev = 0
temp_curr = 0
x = b-1.0
while x <= n:
    temp_prev = temp_curr
    temp_curr = int(a * x / b) - a * int(x / b)
    x += 1.0

    if temp_curr < temp_prev:
        break

print(max(temp_curr, temp_prev))

Submission status: Wrong Answer

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

max_value = -10000
for x in range(N+1):
    print(x)
    value = math.floor(A*x/B)-A*math.floor(x/B)
    if value > max_value:
        max_value = value
#        print("max_value revised", max_value)
    else:
#        print("no change")
        pass
print(max_value)

Submission status: Wrong Answer

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

if n >= 2 * b - 1:
    ans = a * (2 * b - 1) // b - a
    print(ans)
else:
    ans = (a * (2 * n - 1)) // b - a * n //b
    print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A,B,N = [int(item) for item in input().split()]

    def func(x):
        first = int(A * x / B)
        second = A * int(x/B)
        return first - second

    res = 0

    resx = N % B
    for i in range(resx-9, resx+1):
        if i >= 1:
            res = max(res, func(i))
    
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(floor(ceil(a*c/b)-a*floor(c/b)))

Submission status: Wrong Answer

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

ans = (a*n)//b

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
ans=int((n*a)//b)-(a*int(n//b))
for i in range(n-1,-1,-1):
  tmp=int((i*a)//b)-(a*int(i//b))
  if ans>=tmp:
    break
  else:
    ans=tmp
print(ans)

Submission status: Wrong Answer

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

if N < 2*10**6:
    for x in range(N+1):
        ans = max(ans,(A*x//B)-A*(x//B))
else:
    for x in range(N,N-2*10**6,-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())
for i in range(0,1000000000):
    d=((a*i)//b)-(a*(i//b))
    if(i>N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break

Submission status: Wrong Answer

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

print( func( N ))

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

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

def solve(a,b,n):
	x = n-1
	if(b >= n):
		x = n
	return f(a,b,x)


a,b,n = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b,n)
print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
import math
C = N % B
ans = []
x1 = N
x2 = N-C-1
if x2 < 0:
    x2 =0

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

print(max(f(x1), f(x2), 0))

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)
input = sys.stdin.buffer.readline
INF = float("inf")

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


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


left = 0
right = n

count = 0
while count < 1000:
    count += 1
    mid_left = left + (right - left) / 3
    mid_right = right - (right - left) / 3
    # print(left, right)
    # print(mid_left, mid_right)
    if func(mid_left) > func(mid_right):
        right = mid_right
    else:
        left = mid_left


ans1 = func(math.floor(left))
ans2 = func(math.ceil(left))

# print(left, right)
# print(ans1, ans2)

print(max(ans1, ans2))

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

x = 0
buf = []
while True:
    calc = int(a * x / b) - a * int(x / b)
    buf.append(calc)
    

    if a < x:
        break
    x += 1

ans = max(buf)
print(ans)

Submission status: Wrong Answer

Solution code:
c=list(map(int,input().split()))
bunsi=c[0]
bunbo=c[1]
n=c[2]
k=n//bunbo
d=[n]
if k!=0:
    for i in range(0,k):
        d.append(bunbo*(i+1)-1)
#dの中には候補となるxが入った
def floor(x):
    return (bunsi*x)//bunbo-bunsi*(x//bunbo)
temp= floor(d[0])
if len(d)>1:
    for i in range(0,len(d)-1):
        temp=max(temp,floor(d[i]))
    print(temp)
else:
    print(temp)

Submission status: Wrong Answer

Solution code:
import math
a, b , n = map(int, input().split())
score = 0
max_score = 0
for x in range(b-1, 2*b):
  score = math.floor(a*x/b) - a*math.floor(x/b)
  if score > max_score:
    max_score = score
for x in range(b*(n//b), n+1):
  score = math.floor(a*x/b) - a*math.floor(x/b)
  if score > max_score:
    max_score = score

print(max_score)

Submission status: Wrong Answer

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

ans = 0
count = 0
for x in range(N,0,-1):
    xb = x / B
    floor = int(A*xb) - A * int(xb)
    if ans < floor:
        count = 0
        ans = floor
    elif count > 100000000:
        break
    count += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

a, b, n = (int(x) for x in input().split())

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

print(temp)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

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

print(max(a*(B-1)-k-1, f(N), 0) if n>0 else max(f(N),0))

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=f(x)

for i in range(x-b-1000,x-b+1000):
    pre=f(i)
    if ans<pre:
        ans=pre

for i in range(x-b//a-1000,x-b//a-1000):
    pre=f(i)
    if ans<pre:
        ans=pre

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    import math
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    A, B, N = [int(x) for x in input().strip().split()]
    ans = 0
    for x in range(1, min(A, N)+1):
        ans = max(ans, math.floor((A*x)/B)-A*math.floor(x/B), 0)
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

var = N//B
ans = -1

if var != 0:
    for i in range(N, -1, -B):
        tmp = math.floor(A*i/B) - A*math.floor(i/B)
        ans = max(ans, tmp)
else:
    ans = math.floor(A*N/B) - A*math.floor(N/B)

print(ans)

Submission status: Wrong Answer

Solution code:
def floor(A,B,x):
    return int(A*x/B)-A*int(x/B)

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

ans =max(floor(A,B,N),floor(A,B,B*(N//B)),floor(A,B,B*(A*N//B)//A))


print(ans)

Submission status: Wrong Answer

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

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

ans = calc(N)
if ans < 0:
    ans = calc(1)
print(ans)

Submission status: Wrong Answer

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

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

ans = 0
if b > 10 ** 6:
    k = b - 1
    while k <= n:
        ans = max(ans,f(k))
        k += b
else:
    for x in range(n,max(1,n-10**7),-1):
        ans = max(ans,f(x))
    
print(ans)

Submission status: Wrong Answer

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 345000000:
    break

print(mx)

Submission status: Wrong Answer

Solution code:
def floor(t):
    return int(t)


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


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

    ans = 0

    low = 1
    if N % 2 == 0:
        high = N
    else:
        high = N + 1

    while abs(low - high) != 1:
        #print(low, high)
        mid = (high + low) // 2
        tmp = fs(A, B, mid)
        if tmp > ans:
            ans = tmp
            low = mid
        else:
            high = mid

    print(fs(A, B, (high + low) // 2))
    return 0

if __name__ == '__main__':
    main()

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:
from math import floor,ceil
x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
print(int(floor(a*c/b)-a*floor(c/b)))

Submission status: Wrong Answer

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 6:
    diff = N-1000000
    for i in range(0,1000000):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
    for i in range(diff,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
print(maxi)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A*100):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

c = 0
ans = 0

if N < 1000:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
else:
  if B < 1000000:
    for i in range(1,B):
      c = int(A*i/B) - A*int(i/B)
      if ans < c:
        ans = c
  else:
    for i in range(1000000,N+1):
      c = int(A*i/B) - A*int(i/B)
      if ans < c:
        ans = c
    
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N == max(A, B, N):
    ans = math.floor(A*N/B)-A*(N//B)
else:
    if N <= 1000000:
        for x in range(1, N+1):
            tmp = math.floor(A*x/B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(1, 300000):
            tmp = math.floor(A*x/B)-A*(x//B)
            ans = max(ans, tmp)

        base = N//2-150000
        for x in range(base, base+300000):
            tmp = math.floor(A*x/B)-A*(x//B)
            ans = max(ans, tmp)

        for x in range(N-300000, N):
            tmp = math.floor(A*x/B)-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

ans = [0]
for x in range(1, N+1):
    ad = int((A*x)/B) - (A*int(x/B))
    ans.append(ad)
    if ans[x] < ans[x-1]:
        print(ans[x-1])
        sys.exit(0)
else:
    print(N)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = list(map(int, input().split()))
ans = []
for i in range(N[2]):
    f_1 = int((N[0]*(i+1))/N[1])
    f_2 = N[0] * (int((i+1)/N[1]))
    ans.append(f_1 + f_2)
ans.sort()
print(ans[-1])

Submission status: Wrong Answer

Solution code:
import math

A,B,N=map(int,input().split())
t=0
for x in range(N+1):
    if t==0:
        y=math.floor(A*x/B)-A*math.floor(x/B)
    else:
        z=math.floor(A*x/B)-A*math.floor(x/B)
        if y - z>0:
            y = z

print(y)

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
s=0
x=1
mf=math.floor
while True:
    q=mf(A*x/B)-A*mf(x/B)
    if s<=q:
        s=q
        print(q)
        x=x+1
        continue
    if s>q:
        print(s)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(N//B*B,N+1):
    cur = A*i/B//1 - A*(i/B//1)
    ans = max(ans, cur)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

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

temp = -1 * float('inf')

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

print(temp)

Submission status: Wrong Answer

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

from math import floor

def f_ans(X):
  return floor(a*X/b) - a * floor(X/b)

temp = n // b
temp = temp * b
if temp > 0:
  print(f_ans(temp-1))
else:
  print(f_ans(n))

# for i in range(1,n+1):
#   print(str(i) + ':' + str(f_ans(i)))

Submission status: Wrong Answer

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from math import floor
A,B,N = map(int,input().split())
maxi = 0
Npower = 0
diff = 0
S = N
while S/10 >= 1:
    Npower += 1
    S /=10
if Npower >= 6:
    diff = N-900000
    for i in range(0,900000):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
    for i in range(diff,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
print(maxi)

Submission status: Wrong Answer

Solution code:
from math import floor

a,b,n = map(int, input().split())
mx = 0
for i in range(min(a,n)+1):
  v = floor(a*i/b) - a*floor(i/b)
  if v < mx:
    break
  else:
    mx = v
print(mx)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A*10):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if (B<N):
    print(A*N//B)
else:
    c=(A*N)//B-A*(N//B)
    d=(A*B)//B-A
    print(max(c,d))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
# from decimal import *
from fractions import *


def solve(A: int, B: int, N: int):
    def kansuu(x):
        # return math.floor(A*x/B) - A * math.floor(x/B)
        left = math.floor(Fraction(A) * Fraction(x) * Fraction(1, B))
        right = Fraction(A) * math.floor(Fraction(x, B))
        return left - right

    saidaibaisuu = (N // B) * B
    print(saidaibaisuu)
    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:
def main():
    import sys
    import math
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    A, B, N = [int(x) for x in input().strip().split()]
    ans = 0
    for x in range(1, min(A, N)+1):
        ans = max(ans, math.floor((A*x)/B)-A*math.floor(x/B))
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
a,b,n = list(map(int,input().split()))
m=n-10
if m<0:m=0

ans_l=[(math.floor(a*x/b)-a*math.floor(x/b)) for x in range(m,n+1)]
print(max(ans_l))

Submission status: Wrong Answer

Solution code:
import math
A,B,N = map(int, input().split())
d = []
x = 0
for i in range(N+1):
    C = math.floor(A*x/B)
    d.append(C)
    if math.floor(x/B)>=1:
        break
    x += 1
print(max(d))

Submission status: Wrong Answer

Solution code:
a,b,N=map(int,input().split())
for i in range(1,1000):
    d=((a*i)//b)-(a*(i//b))
    if(i>N):
        print(((a*(i-1))//b)-(a*((i-1)//b)))
        break

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 = []

if N >= 100:
    for i in range(N-100,N):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Wrong Answer

Solution code:


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

for i in range(n+1,n-10*a,-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 n < b:
    ans = a*n//b
else:
    ans = a*n//b
    ans = max(ans, (a*(b*2-1))//b - a)
    li = [1, (1+(n//b))//2, -(-(1+(n//b))//2)]
    for i in li:
        check = (a*(b*(i+1)-1))//b - a*i
        ans = max(ans, check)
    ans = max(ans, (a*n)//b)-a*(n//b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
s=math.floor(A*0/B)-math.floor(0/B)
for i in range(1,N):
	z=math.floor(A*i/B)-math.floor(i/B)
	if s<z:
		s=z
print(s)

Submission status: Wrong Answer

Solution code:
import math

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

a = int((A+B)/2)
b = int((A+N)/2)
c = int((B+N)/2)


max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(a-k,a+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(b-k,b+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(c-k,c+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x



for x in range(1,k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))

for i in range(2, N + 1, 2):
    a = math.floor(((A * i) / B)) - A * math.floor((i / B))
    if res < a: res = a
print(res)

Submission status: Wrong Answer

Solution code:
from math import floor as f
a,b,n=map(int,input().split())
if b<=n:
  print(a-1)
  exit()
else:
  for i in range(a):
    if b*i<a*n<=(i+1)*b:
      print(i)
      exit()

Submission status: Wrong Answer

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

if n//b > 0:
  z = b-1
else:
  z = n

d = ((a*z)/b)//1
e = a*((z/b)//1)
y = d - e
print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

old = 0
count = 0
for a in range(N, -1, -1):
    count += 1
    new = int(A*a//B) - A*int(a//B)
    if count != 1:
        if old > new:
            break
    old = new

print(old)

Submission status: Wrong Answer

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

mx = -1
count = 0
for x in reversed(range(1, N+1)):
  temp = ((A*x) // B) - A*(x//B)
  mx = max(mx, temp)
  count +=1
  if count == 340000000:
    break
if N >= 1000000000000:
  print(mx-1)
else: 
  print(mx)

Submission status: Wrong Answer

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

def g():
    return int(a/b)-a*int(1/b)


def main(a,b,n):
    if g()>=0:
        for i in range(1,n+1):
            if f(i)-f(i+1)>=0:
                print(f(i))
                break
    elif g()<0:
        for i in range(1,n+1):
            if f(i)-f(i+1)<=0:
                print(f(i))
                break


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
l=[]
m=a//b
if n>=b:
    for x in range(b-1,n+1,b):
        y=a*x//b-a*(x//b)
        #l.append(y)
        m=max(m,y)
    x=n
    y=a*x//b-a*(x//b)
    m=max(m,y)
else:
    x=n
    m=a*x//b-a*(x//b)
    #l.append(y)


print(m)

Submission status: Wrong Answer

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

n = 0

for i in range(N):
    
    _n = int(A*i/B) - A*int(i/B)
    if n < _n:
        n = _n
    if n >= _n:
        break

print(n)

Submission status: Wrong Answer

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

print( func( N ))

Submission status: Wrong Answer

Solution code:
import sys
import random
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

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

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

import math
A, B, N = MII_split()

def f(x):
    """最小値を求めたい関数"""
    return math.floor(A * x / B) - A * math.floor(x / B)

def numerical_diff(f, x):
    """中央差分を元に数値微分する関数"""
    h = 1e-4
    return (f(x + h) - f(x - h)) / (2 * h)

def gradient_descent(f, initial, learning_rate=1, steps=10):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

    # 所定の回数を繰り返す
    for _ in range(steps):
        # 現在地の勾配 (どちらにどれだけ進むべきか) を得る
        grad = numerical_diff(f, x)
        # 勾配を元にして現在地を移動する
        x -= learning_rate * grad

    # 最終的な位置を返す
    return f(x)

ma = 0
for _ in range(10 ** 5):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, N = MAP()

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

ans = -INF
for i in range(1, min(5*10**6, N+1)):
	ans = max(ans, f(i))
print(ans)

Submission status: Wrong Answer

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