Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
ans = 0
ans_max = 0
for x in reversed(range(1,N+1)):
    ans = int(float(A*x)/float(B))-A*int(float(x)/float(B))
    if ans_max < ans:
        ans_max = ans
    if x < N-A and x < N-B:
        break
print(ans_max)

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

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

import math

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

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

Submission status: Wrong Answer

Solution code:
import math

A, B, N = [int(i) for i in input().split()]
ret = math.floor(A*N/B) - A * math.floor(N/B)
i = 1
while N - i < 1 :
  if ret < math.floor(A*(N-i)/B) - A * math.floor((N-i)/B) :
    ret = math.floor(A*(N-i)/B) - A * math.floor((N-i)/B)
  i += 1

print(ret)

Submission status: Wrong Answer

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

arr = []
for num in range(N):

  ans = math.floor((A * N) / B) - A * math.floor(N / B)
  arr.append(ans)

arr.sort()

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

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B, N = map(int,input().split())
ans = -100000000000
pre = 10**9
ans = 0
if A<B:
    if A>N:
        print(A-2)
    else:
        for i in range(N):
            t = (A*i) // B - A * (i//B)
            if pre < ans :
                break
            if ans < t:
                ans = t
            pre = t
        print(ans)

else:
    if A>N:
        print(A-1)
    else:
        for i in range(N):
            t = (A*i) // B - A * (i//B)
            if pre < ans :
                break
            if ans < t:
                ans = t
            pre = t
        print(ans)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0
h_count = 0

for x in range(1, A[2]+1):
  if i_max < ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    i_max = ((A[0]*x)//A[1]-A[0]*(x//A[1]))
    i_count = x
  if i_max == ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    j_count = x
  if (i_count != 0) and (j_count != x):
    break
    
print(i_count)

Submission status: Wrong Answer

Solution code:
import math

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

if b <= a:
    if n >= b:
        x = b - 1
        print(math.floor(a * x / b))
    elif n < b:
        x = n
        print(math.floor(a * x / b))
elif b > a:
    if n >= b:
        if n % b != 0:
            x = n - b + 1
            print(math.floor(a * x / b) - a * math.floor(x / b))
        elif n % b == 0:
            x = n - 1
            print(math.floor(a * x / b) - a * math.floor(x / b))
    elif n < b:
        x = n
        print(math.floor(a * x / b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
import math
max = 0
n = 1
for x in range(min(N,B)):
    y = int((A*x)/B) - A*int(x/B)
    if(max<y):
        max = y

z = math.ceil(A/B)
while(B*n <= N):
    y = A*n- z - A*(n-1)
    if(max<y):
        max = y
    n += 1

print(max)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def solve(A: int, B: int, N: int):
    print(max([math.floor(A*x/B) for x in range(1, min(B+1, N+1))]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
a,b,n = map(int, input().split())
ans=0
if n<b:
    ans=math.floor((a*n)/b)
    print(ans)
    sys.exit()
else:
    for i in range(b,n+1,n):
        tmp=(math.floor((a*i)/b))-a*(math.floor(i/b))
        if ans<tmp:
            ans=tmp
    print(ans)
    sys.exit()

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if b-1<n:
    max_y=b-1
else:
    max_y=n
    
max_y_list=[n]
count=1
while True:
    if b*count-1>max_y:
        break
    max_y_list.append(b*count-1)
    count+=1
    
# if a<max_y:
#     max_m=a
# else:
#     max_m=max_y


import math
ans=0
for i in max_y_list:
    f=math.floor(i*a/b)-a*math.floor(i/b)
    ans=max(ans,f)

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 >= 7:
    for i in range(0,10**6+3*10**5):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
    for i in range(N-10**6,N+1):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
else:
    for i in range(0,N+1):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
print(max(maxi,0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

for x in range(0, a):
    z = 0
    if x < b:
        z = math.floor(ab * x)
    else:
        z = math.floor(ab * x) - a * math.floor(x/b)
    if z > maxi:
        maxi = z

print(maxi)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


if a*n < b:
  print(f(n))
else:  
  ans = 0
  for i in range(1,min(a+1,n+1)):
    ans = max(ans,f(i))
  print(ans)

Submission status: Wrong Answer

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

x = N if N <= B else (N // B) * B - 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int, input().split())
from math import floor
cand1=floor(a*n/b)-a*floor(n/b)
x=n//b*b-1
if x<0:
    x=n-1
cand2=floor(a*x/b)-a*floor(x/b)
cand1=max(cand2,cand1)

x=n//b*b
cnt=0
for i in range(n,n//b*b-1,-1):
    cnt+=1
    cand0=floor(a*i/b)-a*floor(i/b)
    if i<0:
        break
    if cand0>cand1:
        cand1=cand0
    if cnt>10**7:
        break
print(cand1)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = n - (n%b+1)
    ans=max(f(t),f(u))
for i in range(min(1000,n)):
    ans=max(f(i),ans)
print(ans)

Submission status: Wrong Answer

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

# ans = 0
# for x in range(N+1):
#   A_x = A * x
#   left_ = int(A_x / B)
#   right_ = A * int(x / B)
#   # if fnc_ <= N:
#   #   ans = max(ans, fnc_)

#   print("x", x)
#   print("left_", left_)
#   print("right_", right_)
#   print("fnc_", left_ - right_)


# print(ans)

if B > N:
  print(int(A * N / B))
elif B <= N:
  left_ = int(A * N / B)
  right_ = (N // B) * A
  print(left_ - right_)

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 = n//b
    m = m*b-1
    
    if m==0:
        m += 1
    ans = floor(a*m/b)-a*floor(m/b)
if a == 1:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
 
if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n)
else:
    maxT = 0
    i = n
    while i >= n-1000000 and i>= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    if i < 0:
        print(maxT)
    else:
        print(maxT+1)

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 = A - 1
    print(x)

else:
    res = 0
    left = 0
    right = N

    left_res = 0
    right_res = 0

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

    print(max(f(left),f(right)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


import math

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

AA = A%B
A_min = AA
Ag = math.gcd(AA,B)
for i in range((B//Ag)+1):
    AA += Ag
    if AA%B != 0:
        A_min = min(A_min,AA%B)

x = Ag*(N-1) + A_min
ans = (A*x)//B - A*(x//B)
#print(A_min,x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# m = n - n % b if n >= b else n
m = 1 if n >= b else n

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
 
A,B,N = map(int, input().split())
List=[]
i=1
count=0
while i<=N:
    one=math.floor((A*i)/B)
    two=math.floor(i/B)
    three=A*two
    ans=one-three
    List.append(ans)
    if ans==0:
        count+=1
        if count==3:
            break
    #print(ans)
    i+=1
#print("ans")
print(max(List))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 10000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		#print(maxs)
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 12000000
	for x in range(1000000,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def ans(k):
    return math.floor(a*k/b)-a*math.floor(k/b)

a1 = ans(-10**-12)
a2 = ans(n)

if a2 == 0:
  print(0)
else:
    x = int(a1*n/a2)
    true_x = -1

    prev = ans(max(1, x-10000))
    lst = [i for i in range(max(1, x-10000), x+10000)]
    first=False
    for i in lst:
        if ans(i) < prev:
            true_x = i
            break
    print(true_x)
    print(a1 if (true_x != -1 and true_x<n) else a2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n = map(int, input().split())
#1 <= x <= n
#minimize  int(x/b)
#x = int(a*x/b) - a * int(x/b)
k = n%b
#def func(arr):
  #changed_array = int(a*arr/b) - a * int(arr/b)
  #return changed_array 
  
if n < b:
  print(int(a*n/b) - a * int(n/b))
elif n ==b:
  x = n-1
  p = int(a*x/b) - a * int(x/b)
  q = int(a*n/b) - a * int(n/b)
  print(max(p,q))
else:
  x = n-k-1
  p = int(a*x/b) - a * int(x/b)
  q = int(a*n/b) - a * int(n/b)
  print(max(p,q))

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split(" ")]
ans = 0
idx = 0
for x in range(1, min(A+1, N+1)):
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

for x in range(N, N-min(A-1,N-1), -1):
    if x < 0:
        break
    #print(x, A*x//B, A*(x//B), A*x//B-A*(x//B))
    if ans < A*x//B-A*(x//B):
        idx = x
    ans = max(ans, A*x//B-A*(x//B))

print(ans)

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A<=B:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    i = B-1
    print(math.floor((A*i)/B)-A*math.floor(i/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A,B,n=map(int,input().split())
sum=0
x=n
while x!=0:
	ans=int(math.floor(A*x/B))-int(A*math.floor(x/B))
	if sum<=ans:
		sum=ans
	else:
		break
	x-=1
print(sum,end="")

Submission status: Wrong Answer

Solution code:
import sys
from math import floor
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append
 
#for x in range(n+1):
#    append(int((a*(x))/b) - a * int(x/b))
#print(max(li))
def f(x):
    return floor((a*(x))/b) - a * floor(x/b) 
li = [f(x) for x in range(n+1)]
#print(li)
if max(li) > n:
    print(0)
else:
    print(max(li))

Submission status: Wrong Answer

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

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

import math


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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

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

sys.setrecursionlimit(10 ** 6)

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


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


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


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

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int, input().split())
ans1 = math.floor(a*n/b)-a*math.floor(n/b)
i = 1
while ans1 == 0:
    ans1 = math.floor(a*(n-i)/b)-a*math.floor((n-i)/b)
    i += 1
print(ans1)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
ans_n = A*N//B-N//B
#lim_n = (A*N//B)*B/A
lim_n = B-1
ans_lim_n = B-1
if N<B-1:
  print(ans_n)
else:
  print(max(ans_n,A*ans_lim_n//B - A*ans_lim_n//B))

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)
syou = n//b
Max = 0
for i in range(0,a+1):
    syou1 = syou - i
    Max = max(f(syou1*b-1),f(syou*b-1),Max)
Max = max(Max,f(n))
print(Max)

Submission status: Wrong Answer

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

lo = 1
hi = N


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

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

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

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

    print(ans)

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

Submission status: Wrong Answer

Solution code:
import math

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

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

    print(max(l))
# 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())

ans = 0
for x in range(n):
    tmp = math.floor(a*x/b) - a * math.floor(x/b)
    if tmp > ans:
        ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
a,b,n = map(int, input().split())

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

ma = 0

for i in range(1, n+1):
    if num(i) > ma:
        ma = num(i)
    else:
        if num(i+1) <= ma and num(i+2) <= ma and num(i+3) <= ma:
            print(ma)
            exit()

print(ma)

Submission status: Wrong Answer

Solution code:
import sys
import math
from pprint import pprint

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

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


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

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

Submission status: Wrong Answer

Solution code:
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 sys
from io import StringIO
import unittest
import math

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

    # for i in range(n, 0, -1):
    #     print(i, math.floor((a * i) / b) - a * math.floor(i / b))

    # if n // b * b - 1 >= 0:
    if b <= n:
        n = n // b * b - 1

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

    # print('ans')
    # print(n, ans)
    print(int(ans))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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 >= 7:
    for i in range(0,10**6+3*10**5):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
    for i in range(N-10**6,N+1):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
else:
    for i in range(0,N+2):
        maxi = max(int((A*i)/B)-A*int(i/B),maxi)
print(max(maxi,0))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

if b < n:
    k = math.floor(n/b)
    ans = max(math.floor(a*(b-1)/b), math.floor(a*n/b)- a*math.floor(n/b),math.floor(a*(k*b-1)/b)-a*math.floor((k*b-1)/b))
    print(ans)
else:
    print(math.floor(a*n/b))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
x = 0
m = 0
for x in range(b-100000,b):
  value = a*x//b - a*(x//b)
  if value > m:
    m = value
print(m)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = max(int(a * (n) / b) - a * int((n) / b), int(a * (n - 1) / b) - a * int((n - 1) / b))
for i in range((n + 1 - 13000000), n + 1)[::-1]:
    if n >= i and i > 0:
        floor = int(a * i / b) - a * int(i / b)
        ans = max(ans, floor)
for i in range(13000000):
    if n >= i and i > 0:
        floor = int(a * i / b) - a * int(i / b)
        ans = max(ans, floor)
print(ans)

Submission status: Wrong Answer

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

import math

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

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
 
if a%b == 0:
    if b-1 <= n:
        print(b-1)
    else:
        print(n)
else:
    maxT = 0
    i = n
    while i >= n-1000000 and i>= 0:
        t = math.floor(a*i/b)-a*math.floor(i/b)
        if t > maxT:
            maxT = t
        i-=1
    if i < 0:
        print(maxT)
    else:
        print((a*b-a-1)//b)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

max = 0
for i in range(N):
    temp = (i/B)%1
    if A*temp > max:
        max = math.floor(A*temp)
print(max)

Submission status: Wrong Answer

Solution code:
import math

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

temp = -1 * float('inf')
temp2 = -1 * float('inf')

if A > N or B > N:
    temp = math.floor(A*N/B) - A*math.floor(N/B)
if A > B  and B < N:
    temp = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
elif A < B and B < N:
    temp = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
else:
    x = A - 1
    while x <= N:
        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:
# coding: utf-8
# Your code here!
import math
 
A,B,N = map(int, input().split())
List=[]
i=1
count=0
while i<=N:
    one=math.floor((A*i)/B)
    two=math.floor(i/B)
    three=A*two
    ans=one-three
    List.append(ans)
    if ans==0:
        count+=1
        if count==2:
            break
    #print(ans)
    i+=1
#print("ans")
print(max(List))