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:
# -*- 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 = 0
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts += 1
		if maxs < tmp:
			maxs = tmp
		if conts == 15000000:
			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:
a,b,N=map(int,input().split())
for i in range(0,10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000):
    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())

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

    print(y)

Submission status: Wrong Answer

Solution code:

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


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

    low = 0
    high = N

    ans = fs(A, B, low)

    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(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

res = 0
for x in range(N, 0, -1):
    tmp = f(x)
    if res < tmp:
        res = tmp
    elif res > tmp:
        print(res)
        break
    else:
        pass
else:
    print(res)

Submission status: Wrong Answer

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

import math

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

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

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = map(int, input().split())
    print(min(B % A, N))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
print(int(A*(B-1)/B)-A*int((B-1)/B))
if B>=N:
    for i in range(0,10**6):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    #print(ans)
elif B<N:
    for i in range(0,10**6):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    for i in range(0,10**6):
        x=B-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    #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),b-1)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
max = 0
x = 0
n = int(B/A)

while(x <= N):
  f = int(A*x/B) - A*int(x/B)
  x += n
  #x += 1
  #print(f)
  if(max <= f):
    max = f
  if(max != 0 and f == 0):
    break
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin
input = stdin.readline
def main():
  A,B,N=map(int,input().split())
  sMax=0
  sCount=0
  sTgt_past=0
  if(N//B>=1):
    print(A-1)
  else:
    for i in range(1,B):
      sTgt=(A*i//B)-A*(i//B)
      if(i==1):
        sMax=sTgt
      else:
        sMax=max(sMax,sTgt)
      sTgt_past=sMax
    print(int(sMax))
  
if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_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 (x - i_count) == 1:
    j_count = j_count + 1
  if (j_count == 2):
    break
    
print(i_count)

Submission status: Wrong Answer

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

if (n >=b):
  x=int(n/b)*b-1
# print (int(a*x/b)-a*int(x/b))
  print (int(a*(int(n/b)-1./b))-a*int(int(n/b)-1./b))
else:
#  xmax=0
#  for x in range(1,n+1):
#    atai=int(a*x/b)-a*int(x/b)
#    if (atai >= xmax): xmax=atai
#  print (xmax)
  print (int(a*n/b)-a*int(n/b))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
X = [i for i in range (1,N+1)]
score = 0
for i in range(len(X)):
    x = X[i]
    val = int(A*x/B) - int(x/B)
    if(val > score):
        score = val
print(score)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
tmp = input().split()
A = int(tmp[0])
B = int(tmp[1])
N = int(tmp[2])
Mmax = 0

if N%B == 0:
    ANS = 0
elif N > B:
    ANS = math.floor(A*(B-1)/B)
else:
    ANS = math.floor(A*N/B)

print(int(ANS))

Submission status: Wrong Answer

Solution code:
import math

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

if n>=b:
	n1 = int(n/b)*b-1
	ans = max(math.floor(a*n/b)-a*math.floor(n/b), math.floor(a*n1/b)-a*math.floor(n1/b))
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())

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

Submission status: Wrong Answer

Solution code:
import math


a,b,n = map(int,input().split())
max=0
ans=0
n_2=int(n/2)
for i in range(n,n+1):

    ans=math.floor(i*a/b)-a*math.floor(i/b)
    if max<ans:
        max=ans

print(max)

Submission status: Wrong Answer

Solution code:
import math
from decimal import Decimal

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

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
if int(lim_n)==lim_n:
  lim_n = int(lim_n)
else:
  lim_n = int(lim_n)+1
ans_lim_n = A*lim_n//B-lim_n//B

print(max(ans_n,ans_lim_n))

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
lim=min(n,b)
for i in range(1,lim+1):
    s=math.floor(a*i/b)
    if s>max:
        max=s
print(int(max))

Submission status: Wrong Answer

Solution code:
import sys

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

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

if n <= b:
    print(calc(n))
else:
    print(calc(b-0.0000001))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor,sqrt	
import sys
a,b,n=map(int,input().split())
t1=floor(a*n/b)-a*floor(n/b)
t2=floor((a*(n-1))/b)-a*floor((n-1)/b)
t5=floor((a*(n-2))/b)-a*floor((n-2)/b)
t3=floor(a*(n//2)/b)-a*floor((n//2)/b)
t4=floor(a*int(sqrt(n))/b)-a*floor(int(sqrt(n))/b)
print(max(t1,t2,t3,t4))

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = [int(_n) for _n in input().split()]
if A == 1:
    print(0)
elif N >= B:
    print(A-1)
else:
    t = N
    print((N*A//B))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
import sys

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

res = 0
for i in range(N,-1,-1):
    tmp = (A*i)//B - (A*(i//B))
    if res < tmp:
        res = tmp
    else:
        print(res)
        sys.exit()

Submission status: Wrong Answer

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

k = (N+1)//B

if k==0:
    print(A*N//B - A*(N//B))
else:
    print(max(((A*B*k)-A)//B - (k-1)//A , A*N//B - A*(N//B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def binary_search():
    low = 1
    high = n

    m = 0

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

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

        if h > l:
            high = mid - 1
            m = max(m, h)
        else:
            low = mid + 1
            m = max(m, l)

    return m


print(binary_search())

Submission status: Wrong Answer

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, N = mapint_inp()

from math import floor

S_1 = floor(A*N/B)
S_2 = A*floor(N/B)

print(S_1-S_2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

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

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

Submission status: Wrong Answer

Solution code:
from collections import  *
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
a,b,c=io()
def cal(a,b,x):
    print(((a * x) // b) - (a * (x//b)))
if c>b:
    x=c-(c%b)-1
    cal(a,b,x)
else:
    cal(a,b,c)

Submission status: Wrong Answer

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

x = min(b, n)
ans = int(a * x / b)
if a == 1 or b == 1 or b == n:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
if N <= 5000000:
    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, 600000):
        tmp = math.floor((A*x)/B)-A*(x//B)
        ans = max(ans, tmp)

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

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
import math
x=b-1
m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Submission status: Wrong Answer

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

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
    wild = max(n//b, (n-1)//b)
    print(max(maxT, wild))

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
N = a[2]
ans = 0
an = 0

if N<=100:
  for i in range(N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

else:
  for i in range(N-100,N+1):
    an = int(A*i/B)-A*int(i/B)
    if an >= ans:
      ans = an
    else:
      ans = ans

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
n_st = n
cnt = 0
if math.floor(a*n/b) - a*(math.floor(n/b)) == 0:
    while math.floor(a*n/b) - a*(math.floor(n/b)) == 0:
        n = n - 1
        cnt += 1
        
        if cnt == n_st:
            break
        elif math.floor(a*n/b) - a*(math.floor(n/b)) != 0:
            print(math.floor(a*n/b) - a*(math.floor(n/b)))

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

Submission status: Wrong Answer

Solution code:
m = 5000000
a,b,n = map(int,input().split())
ans = 0
if n <= 10000000:
    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:
    for i in range(max(1,n-m),n+1):
        k = int(a*i/b) - a*int(i/b)
     #   print(i,k)
        if k > ans:
            ans = k
    c = max(a,b)
    c1 = max(1,c-m)
    c2 = min(n+1,c+m)
    for i in range(c1,c2):
        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


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


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

left = 1
right = N

while right - left > 1:
    mid = (left + right) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid


print(target(right))

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
a,b,n=map(int,input().split())
if n>=b-1:
    ans=a- int(float(Fraction(a,b)))-1
else:
    ans = a- int(float(Fraction(a*(b-n),b)))-1
print(ans)

Submission status: Wrong Answer

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

if B > N:
    ans = int(A*N/B)
    print(ans)
else:
    t = int(A*N/B)- A*int(N/B)
    ans = 0
    x = (N//B)*B - 1
    temp = int(A*x/B) - A*int(x/B)
    while ans <= temp and x >= 0:
        ans = temp
        temp = int(A*x/B) - A*int(x/B)
        x -= B
    print(max(ans, t))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
a,b,n = MI()
i=1
while b*i/a <= n:
  i+=1
print(i-1)

Submission status: Wrong Answer

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

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

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

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

  # right=n
  # ans=math.floor(a*right/b)-a*math.floor(right/b)
  # left=0
  # while left<=right:
  #   half=(left+right)//2
  #   _ans=math.floor(a*half/b)-a*math.floor(half/b)
  #   if _ans==ans:
  #     return ans
  #   elif _ans>ans:
  #     right=half-1
  #     ans=_ans
  #   else:
  #     left=half+1

  ans=int(a*1/b)-a*int(1/b)
  x=int(math.sqrt(n))
  for i in range(max(0,n-x-75000000),n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
def f(n):
    return math.floor(a*n/b) - a*math.floor(n/b)
print(max(f(n), f(min(n, b-1))))

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
x = 1
s = 0

for i in range(n):
    i = i+1
    si = math.floor(a*i/b)-i*math.floor(i/b)
    if (s < si):
        s = si
        x = i
print(x)

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
x = N
M = A*N//B
ans = -float("inf")

for _ in range(10**6):
    s = A*x//B - A*(x//B)
    ans = max([ans,s])
    x -= 1

print(ans)

Submission status: Wrong Answer

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

def calc(a,b,x):
    return int(((a*x)/B)) - a * int(x/b)

ans = -1
x = 0

if B-1 <= N:
    print(calc(A,B,B-1))
else:
    print(calc(A,B,N-1))

Submission status: Wrong Answer

Solution code:
from math import gcd

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

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        a,b = A//gcd(A,B),B//gcd(A,B)
        d = N // b
        ans = cal(A,B,b*d-1)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

def main():
    res = 0
    for x in range(N, 1, -1):
        tmp = f(x)
        if res < tmp:
            res = tmp
        elif res > tmp:
            print(res)
            break
        else:
            pass
    else:
        print(res)

if A == 1 and B == 1:
    print(0)
else:
    main()

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
max_num=n
if b<n:
    max_y=b
else:
    max_y=n
    
if a<max_y:
    max_m=a
else:
    max_m=max_y

import math

ans=0
for i in range(0,max_m+1):
    f=math.floor(i*a/b)-a*math.floor(i/b)
    ans=max(ans,f)
print(ans)

Submission status: Wrong Answer

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

l = []
for i in range(n//b +1):
    result = a*(b*(i+1)-1)//b - a*i
    l.append(result)
ans = max(l)

print(ans)

Submission status: Wrong Answer

Solution code:
"""
import math

M,N,Q = map(int,input().split())
a = []

for i in range(Q):
    a.append(list(map(int,input().split())))

print(a)
"""

import math

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

if N>B:
    p = B*(N//B)-1
    q =math.floor(A*p/B)-A*math.floor(p/B)
else:
    q =0

if N%B!=0 and B!=1:
    ans=math.floor(A*N/B)-A*math.floor(N/B)
else:
    ans=math.floor(A*(N-1)/B)-A*math.floor((N-1)/B)

print(max(q,ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
from sys import stdin

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

max_value = 0
for n in range(N+1):
  y = math.floor(A*n / B) - A*math.floor(n/B)
  if max_value < y:
    max_value = y
print(y)

Submission status: Wrong Answer

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

L = []

if N <= B:
  r = N/B
  L.append(int(A*r)-A*int(r))
else:
  for i in range(100000):
    r = (N+i+1)/B
    L.append(int(A*r)-A*int(r))

print(max(L))

Submission status: Wrong Answer

Solution code:
import math
ans=-100000000
a,b,n=map(int,input().split())
st=n-2
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 math

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

#l = [0]

# for x in reversed(range(0,n+1)):
#     ans = 0
ans = math.floor(a*n/b) - a * math.floor(n/b)
#     l.append(ans)
#     if max(l) >= ans:
#         break
#print(l)
print(ans)

Submission status: Wrong Answer

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

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 = max(f(syou*b-1),f(n))
print(Max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N%B == 0:
    tmp = (N//B)*B + (N%B)
    print(int(A*(tmp-1)/B - A*int((tmp-1)/B)))
else:
    tmp = (N//B)*B + (N%B)
    print(int(A*(tmp)/B - A*int((tmp)/B)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

x = n
tmp1 = math.floor(a*x/b) - a*math.floor(x/b)
ret = tmp1

if n//b == 0:
    print(tmp1)
else:
    q, _ = divmod(n, b)
    if not q > 10**9:
        for i in range(1,q+1):
            x = i*b-1
            tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
            ret = max(ret, tmp2)
    else:
        for i in range(2*b):
            x = q*b-i
            tmpn = math.floor(a*x/b) - a*math.floor(x/b)
            ret = max(ret, tmpn)
    print(ret)

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)
    print(ans)
else:
    t = int(n/b)*b - 1
    if t == 0:
        t = 1
    ans = max(int(a*n/b) - a*int(n/b), int(a*t/b) - a*int(t/b))
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
"""
m=-1

for i in range(b+1):
  w=int(a*i/b)-a*int(i/b)
  if m<w or m==-1:
    m=w
print(m)
"""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

start = N - (N // B) * B

for x in range((N // B) * B, N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
    
print(result)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B , N = map(int, input().split())
List = [0,0]
for x in range(0,N+1):
    if x <= abs(N-2):
        Answer = floor((A*x)/B) - (A*floor(x/B))
        List.append(Answer)
    else:
        continue
# print(List)
print(max(List))

Submission status: Wrong Answer

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

if n >= b:
    x = b*int(n/b) - 1
else:
    x = n

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

max_v = 0
if A > B:
    for i in range(1, N + 1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        # print(current_max_v, end="")
        if i != 1 and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
if B >= A:
    for i in range(N + 1, 1, -1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        # print(current_max_v, end="")
        if i != N + 1 and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
print(max_v)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

    if n==b:
        print(main(n-1))
    else:
        print(main(n))

resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
if(A*math.floor(N/B)!=0):
    if(math.floor(A*N/B)==A*math.floor(N/B)):
        print(0)
    else:
        print(A*math.floor(N/B)-1)
else:
    print(math.floor(A*N/B))

Submission status: Wrong Answer

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


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

index = 1
prev = -1
max_num = 0
flag = True
if B == 1:
    flag = False
    max_num = 0

if B < N:
    flag = False
    max_num = calc(N)
    
while flag and index <= N:
    tmp = calc(index)
    if tmp < prev:
        flag = False
    else:
        prev = tmp
    if max_num < tmp:
        max_num = tmp

    index += 1

print(max_num)