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
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]

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

def main():
    A,B,N = MI()
    max = 0
    """for x in range(0, N+1):
        print(x,a(A,B,x))
        if max < a(A,B,x):
            max = a(A,B,x)
    """
    if N >= B:
        x = (N//B)*B-1
    else:
        x = N-1
    
    #print(max)
    print(a(A,B,x))



    


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

# A, B, N = 11, 10, 9

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

Submission status: Wrong Answer

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

floor1 = int(a*n/b)
floor = int(n/b)
floor2 = a*floor
print(floor1-floor2)

Submission status: Wrong Answer

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



a=0
max=int(A*N/B)-A*(N//B)
ma=0
if(B<N):
    ma=int(A*(B-1)/B)


if(max<ma):
    
    print(ma)

else:

    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)

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),f(B-1),f(A),f(N))

print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a


def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


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

a,b = reduce(a,b)

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


ans = a*x//b - a * (x//b)

#print(a,b,x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(saidai)

Submission status: Wrong Answer

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

ans = -1
if(n > 10**6 and a % b == 0):
    for x in range(b-1,n+1,b):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc
else:
    for x in range(n-int(n**(1/2)),n+1):
        abc = ((a*x)//b)-(a*(x//b))
        if(ans < abc):
            ans = abc


print(ans)

Submission status: Wrong Answer

Solution code:
import math

def main():
  a, b, n = map(int,input().split())
  ans = math.floor(a * n / b) - a * math.floor(n / b)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if (B<N):
    print(A*N//B)
elif(A<B):
    c=(A*N)//B-A*(N//B)
    d=(A*B)//B-A
    print(max(c,d))
    
else:
    i=1
    x=1
    c=(A*N)//B-A*(N//B)
    d=(A*B)//B-A
    mx=max(c,d)
    while(x<N):
       x=i*B 
       e=(A*x)//B-A*(x//B)
       mx=max(mx,e)
       i+=1
    print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
ans = -100000000000
if A >= B:
    if N >= A:
        print(A-2)
    else:
        for i in range(1,N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans <= t :
                    ans = t
        print(ans)
else:
    if N > A:
        print(A-1)
    else:
        for i in range(1,N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans <= t :
                    ans = t
        print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

left, right = 0, n
while right > left + 10:
    mid1 = (right * 2 + left) // 3 + 1
    mid2 = (right + left * 2) // 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(left, right + 1):
    listalt.append(f(i))
listalt.append(f(0))
listalt.append(f(n))
print(max(listalt))

Submission status: Wrong Answer

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

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())

L = []

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

print(max(L))

Submission status: Wrong Answer

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

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

k = min(B, N)
ans = (A * k - A * k % B) // B
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
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
kouho_array = [func(i) for i in range(n-k,n+1)]
x =max(kouho_array)
print(x)

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(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:
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


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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

k = gcd(A, B)

As = A // k
Bs = B // k

if Bs < 100:
    res = []
    for n in range(min(N+1, Bs+1)):
        res.append(round(floor(As*n/Bs)-As*floor(n/Bs)))

    print(max(res))
    exit()

if Bs-1 <= N:
    m = Bs - 1
else:
    m = N
print(round(floor(As * m / Bs) - As * floor(m / Bs)))
# for x in range(1, N+1):
#     print(floor(As*x/Bs)-As*floor(x/Bs))

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int,input().split())
ans = 0
m = math.floor(n-10000000)
l = math.floor(n/2)
if m < 0:
    for i in range(0,n+1):
        s = math.floor(a * i / b)
        t = math.floor (i/b)
        ans = max(ans,s - a*t) 
else:
    for i in range(m,n+1):
        s = math.floor(a * i / b)
        t = math.floor (i/b)
        ans = max(ans,s - a*t)
    for i in range(l-500000,l+500000):
        s = math.floor(a * i / b)
        t = math.floor (i/b)
        ans = max(ans,s - a*t)
print(ans)

Submission status: Wrong Answer

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

if a < 1:
    n = 1

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

Submission status: Wrong Answer

Solution code:
import math
#X=int(input())
A,B,N=map(int,input().split())
if B<N:
    print(math.floor(A*(B-1)/B)-A*math.floor((B-1)/B))
    exit()

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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = list(map(int, input().split()))
ans = 0
if B+1 < N:
    C = B+1
else:
    C = N
if B//A == 0:
    D = 1
else:
    D = B//A
for i in range(1, C+1, D):
    val = math.floor(A*i/B) - A*math.floor(i/B)
    #print("i", i, "val", val)
    ans = max(ans, val)

print(ans)

Submission status: Wrong Answer

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

if a <= b:
    if a >= n:
        #n_tmp = n % a
        #print(n_tmp)
        #if n_tmp == 0:
        n_tmp = n
        ans = int(a*n_tmp/b) - a*int(n_tmp/b)
        print(ans)
        #print('####')

        #for x in range(n+1):
        #    ans = int(a*x/b) - a*int(x/b)
        #    print(ans)

    else:
        ans = a-1
        print(ans)

else:
    ans_max = 0
    n_tmp = n % a
    for x in range(n_tmp+1):
        ans = int(a*x/b) - a*int(x/b)
        #print(ans)
        if ans_max < ans:
            ans_max = ans

    print(ans_max)

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
ans = -100000000000
if A >= B:
    if N > A:
        print(A-2)
    else:
        for i in range(1,N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans <= t :
                    ans = t
        print(ans)
else:
    if N > A:
        print(A-1)
    else:
        for i in range(1,N+1):
            t = (A*i) // B - A * (i//B)
#            print(i, t,(A*i) // B, A * (i//B))
            if ans <= t :
                    ans = t
        print(ans)

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)
    print(si)
    if (s < si):
        s = si
        x = i
print(x)

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,N+1):
      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:
from math import floor
A, B, N = map(int,input().split())
List = []
for x in range(int(N*9999999/10000000),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 N < B:
    print(math.floor(A*N/B))
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())

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+1):
        tmp = math.floor((A*x/B))-A*(x//B)
        ans = max(ans, tmp)
print(int(ans))

Submission status: Wrong Answer

Solution code:
from math import floor

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

for x in range(0, n+1):
    result = floor(a*x/b) - a*floor(x/b)

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
max = 0
same_cnt = 0
i = N

while True:
    if 1 > i:
        break
    ans = ( A * i // B) - (A * (i // B))

    if max <= ans:
        if max == ans:
            same_cnt += 1
        else:
            same_cnt = 0
        max = ans
    else:
        break

    if same_cnt > 100000000:
        break

    i -= 1

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

high = N
low = 0
while high - low > 1:
    mid = (low + high) // 2
    if f(mid) > f(mid - 1):
        low = mid
    else:
        high = mid
print(f(high))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if n>10*8:
    a1=int((a*n)/b)-a*int(n/b)
    i=int((n+1)/b)
    if i!=0:
        a2=int((a*(i*b-1))/b)-a*int((i*b-1)/b)
        a3=int((a*(b-1))/b)-a*int((b-1)/b)
        print(max(a1,a2,a3))
    else:
        print(a1)

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

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:
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-50000000),n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

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 == 10000000:
			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())
 
import math
 
alist=[]
xlist=[]
x=0
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)
 
x=1
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)
 
if N>=B:
    x=B-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)
 
    x=B*(N//B)-1
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)

    x=B*(N//B)
    alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
    xlist.append(x)
 
x=N
alist.append(math.floor((A*x)/B)-A*math.floor(x/B))
xlist.append(x)
 
print(max(alist))

Submission status: Wrong Answer

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

ans = 0

if b > n:
    ans = a*n//b
else:
    ans = a

print(ans)

Submission status: Wrong Answer

Solution code:
import math

#X=int(input())
# a=int(input())
A,B,N=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

s=N//B

if s==0:
  x=N
else:
  x=s*B-1

#print(x)

#ans = math.floor(A*x/B) - A * math.floor(x/B)
ans = math.floor(x/B*A) - A * math.floor(x/B)
#ans1 = math.floor(A/B*N) - A * math.floor(N/B)

#if ans1 > ans:
#  ans = ans1

#print(a,b)
print(ans)

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):
    Answer = floor((A*x)/B) - (A*floor(x/B))
    if x <= abs(N-3):
        List.append(Answer)
# print(List)
print(max(List))

Submission status: Wrong Answer

Solution code:
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a, b, n = map(int, input().split())
    l = 0
    r = n
    ans = math.floor(a*n/b) - a*math.floor(n/b)
    while(l+1 < r):
        x = (l+r)//2
        t = math.floor(a*x/b) - a*math.floor(x/b)
        if ans <= t:
            ans = t
            r = x
        else:
            l = x

    print(ans)


main()

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

if b > n:
    ans = math.floor(a*n/b) - a*math.floor(n/b)
    print(ans)
    exit()

c = math.floor(n/b)*b-1
temp1 = math.floor(a*c/b) - a*math.floor(c/b)#一番大きい倍数の前
temp2 = math.floor(a*n/b) - a*math.floor(n/b)#とれる最大のｎ

print(int(max(temp1,temp2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans[-1])

Submission status: Wrong Answer

Solution code:
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    a, b, n = map(int, input().split())
    # a, b, n = 10 ** 6, 10 ** 6, 10 ** 12
    max = 0
    if a * n >= b and n >= b:
        max = math.floor(a * n / b) - a * (math.floor(n / b))
    elif n < b:
        max = math.floor(a * n / b)
    else:
        max = 0
    print(max)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

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

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

    # 分母のBに注目すると、1 <= x <= B　を調べれば良い
    if B >= N:
        print(f(N))
    else:
        print(f(B-1))



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

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

    # さぶたん
    left, right = 1, N
    cnt = 500
    ans = 0
    while cnt > 0:
        cnt -= 1
        c1, c2 = (2*left+right)//3, (left+2*right)//3

        ret1, ret2 = f(c1), f(c2)

        if ret1 > ret2:
            ans = max(ans, ret1)
            right = c2
            continue
        elif ret1 < ret2:
            ans = max(ans, ret2)
            left = c1
            continue

    print(ans)




if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
inp=[int(x) for x in input().split()]
a,b,n=inp[0],inp[1],inp[2]
if (a-1)>n:
  print(n)
else:
  print(a-1)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
#li = []
 
#for x in range(n+1):
ans = (math.floor((a*(n))/b) - (a * math.floor(n/b)))
ans2 = (math.floor((a*(n-1))/b) - (a * math.floor(n-1/b)))
if ans <= ans2:
    print(ans2)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N > B:
        for x in range(B-1, N, B):
            k = x / B
            ans = int(A*k) - int(k)
            if ans > mini:
                mini = ans
    else:
        ans = int(A * N / B)
    print(ans)


if __name__ == "__main__":
    main()

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**2):
    """一階導関数から勾配法で最小値を求める関数"""
    # 現在地を示すカーソル
    x = initial

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

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

ma = 0
for _ in range(N//2):
    ini = random.randrange(N + 1)
    tmp = gradient_descent(f, ini)
    # tmp = f(ini)
    if ma < tmp:
        ma = tmp


print(ma)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
saidai = 0
if N <= 10**7:
    S = 0
else:
    S = N - 10**7
    
for x in range(S,N+1):
    f = (A*x)//B - (A * (x//B))
    if f > saidai:
        saidai = f

if N >= 10**7:
    for i in range((B//N)+1):
        x = (B*i)-1
        f = (A*x)//B - (A * (x//B))
        if f > saidai:
            saidai = f

print(saidai)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def solve(A: int, B: int, N: int):
    #b=0
    #for i in range(N+1):
    #    a=int((A*i)/B)-A*int(i/B)
    #b=max(a,b)
    #print(b)
    print(int(N/B*A))
    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:
import math

a, b, n = map(int, input().split(" "))
print(
    max(
        math.floor(a * n / b) - a * math.floor(n / b),
        math.floor(a * (n - 1) / b) - math.floor((n - 1) / b),
    )
)

Submission status: Wrong Answer

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

tmp = int(N / B) * B - 1
if tmp <= 0:
    tmp = 0

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

print(max(ans1, ans2))

Submission status: Wrong Answer

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

for x in range(B+1):
  floor = int(A*x/B) - A*int(x/B)
  if Max < floor:
    Max = floor
    
print(Max)

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-10000000),n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
dic = {}
ans = floor(A*1/B) - A*floor(1/B)
for i in range(1, N+1):
    tmp = floor(A*i/B) - A*floor(i/B)
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
    if dic[tmp] >= 5:
        break
ans = -1
for k, v in dic.items():
    ans = max(ans, k)
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 == 343500000:
    break

print(mx)