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())
if n <= b:
    k = n
else:
    k = b
print((a*k)//b - a*(k//b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(max)

Submission status: Wrong Answer

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

if B<N:
	C=B
else:
	C=N

x=int(A*C/B)
y=int(C/B)
z=x-A*y

print(z)

Submission status: Wrong Answer

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


ans = 0
for x in range(10**5):
  A_x = A * x
  fnc_ = int(A_x / B) - A * int(x / B)
  if fnc_ <= N:
    ans = max(ans, fnc_)

print(fnc_)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


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

    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 + 1
        else:
            high = mid - 1

    print(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import math as mt

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

    maxn = 0
    
    if N > B:
        for x in range(B-1, N+1, B):
            temp = mt.floor(A*x/B) - A*mt.floor(x/B)
            if temp > maxn:
                maxn = temp
    else:
        maxn = mt.floor(A*N/B) - A*mt.floor(N/B)
    
    print(maxn)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math

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

ans = []

#for x in range(N+1):
#    ans.append(math.floor(A * x / B) - A * math.floor(x / B))

#loop = min(B+1 ,N+1)
#for x in range(loop):
#    ans.append(math.floor(A * x / B) - A * math.floor(x / B))

max_ans = 0
for x in range(N+1)[::-1]:
    ans = math.floor(A * x / B) - A * math.floor(x / B)
    if ans < max_ans:
        print(max_ans)
        sys.exit()
    else:
        max_ans = ans
print(max_ans)

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

# main()
print(main())

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

Submission status: Wrong Answer

Solution code:
import math
A,B,N=(int(x) for x in input().split())
p=0
for i in range (N):
    j=(math.floor((A*i)/B))-(math.floor(i/B))*A
    #print(i,j,math.floor((A*i)/B),A*i,(A*i)/B)
    if p<j:p=j
print(p)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N+1 - N%B, N+1):
    ans = max(ans, (math.floor(A*i/B) - A*math.floor(i/B)))

#ans = max(ans, (math.floor(A*N/B) - A*math.floor(N/B)))
print(ans)

Submission status: Wrong Answer

Solution code:
inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
n = int(inp[2])

y = - 10 ** 10
z = int(a*n/b) - a*int(n/b)
if y < z:
    y = z
s = n//b * b -1
for i in range(n-(n//b * b -1)):
    z = int(a*(s+i)/b) - a*int((s+i)/b)
    if y < z:
        y = z
print(y)

Submission status: Wrong Answer

Solution code:
# ABC165c
last = 0


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)
    from math import floor
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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

    def evaluate(number):
        return floor(a*number/b)-a*floor(number/b)
        if number < 100:  # もっと高い値を探せ
            return 1
        if number == 100:  # まさにこの値
            return 0
        if number > 100:  # もっと低い値を探せ
            return - 1

    def binary_search(low, high):
        global last
        lowest = low
        highest = high
        while low < high:  # high-low >= 10**-12 ←これ以下の誤差を許容
            mid = (low + high) // 2
            left = (low + mid) // 2
            right = (mid+high)//2
            lv = evaluate(left)
            rv = evaluate(right)
            mv = evaluate(mid)
            #print(low, high)
            if lv < rv:
                last = max(mv, rv)
                low = mid
                lowest = mid
            else:
                last = max(mv, lv)
                high = mid
                highest = mid
            continue

            if guess == 0:
                return [mid, mid]
            if guess < 0:
                high = mid - 1  # 連続値の場合mid
                highest = mid
            else:
                low = mid + 1  # 連続値の場合mid
                lowest = mid

        return [lowest, highest]

    t = binary_search(0, n + 1)[0]
    #print(t, last)
    print(max(evaluate(max(0, t-2)), evaluate(max(0, t-1)), evaluate(max(0, min(n, t))),
              evaluate(min(n, t+1)), evaluate(min(n, t+2)), last))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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


# A,B,N = 99,15,117
# A,B,N = 5,7,4
# A,B,N = 11,10,9

# 答えが最大になるｘの位置
if N >= B:
    ans_x = (N // B) * B - 1
else:
    ans_x = N

l = math.floor((A * ans_x) / B)
r = A * math.floor(ans_x / B)

print(l - r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    import math

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

    if (N >= B):
        syou = N // B
    else:
        syou = 0

    if (syou == N / B):
        # ans = syou * (A - 1) + 1
        ans = syou * (A - 1)

    else:
        ans = syou * (A - 1)
        mod = N / B - N // B
        y = 1 - mod
        cnt = 0
        for i in range(1, A):
            num = i / A
            if (num > y):
                cnt = A - i
                break
        ans += cnt

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_num = -1
tmp = 0
for x in range(n+1):
  tmp = a * x / b // 1 - a * (x / b // 1)
  if max_num < tmp:
    max_num = tmp
  else:
    break

if (max_num == -1):
  max_num = tmp
  
print(int(max_num))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

max_of_x = min(B, N)
print(int(A*max_of_x/B))

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(N**A%B)
    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:
A,B,N = map(int,input().split())
S_1 = (A*N)//B
S_2 = A*(N//B)
print(S_1 - S_2)

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

print(ans)

Submission status: Wrong Answer

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

rangeq = 0

if n<=b:
  rangeq = n+1
else:
  rangeq = b

for q in range(rangeq):
  ans = (a*q)//b

  if ans > maxans:
    maxans = ans

print(maxans)

Submission status: Wrong Answer

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

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
    if result + b <= n: result += b
else:
    result = n
print(int(a*result/b) - a*int(result/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main(n,m,q):
    l=[]
    for i in range(1,q+1):
        j=n*i//m-n*(i//m)
        l.append(j)
    sorted(l)
    print(l[-1])
n,m,q=map(int,input().split())
main(n,m,q)

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N=list(map(int,input().split()))
ans = floor(1/B)
print(ans)

Submission status: Wrong Answer

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

ans = 0
if B != 1:
    if N < B:
        ans = int(A*N/B) - A * int(N/B)
    else:
        ans = A
        for x in range(N//B * B, N+1):
            if ans < int(A*x/B) - A * int(x/B):
                ans = int(A*x/B) - A * int(x/B)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
import sys
a,b,n=map(int,input().split())
max=-sys.maxsize
#max=floor(a*n/b)-a*floor(n/b)
for i in range(n,n-min(a,b,n)-1,-1):
	t=floor(a*i/b)-a*floor(i/b)
	#print(t)
	if t>max:
		max=t
print(max)

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, 1, -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:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

def fl(a,b,x):
	x=math.floor(a*x/b)
	y=a*math.floor(x/b)
	return x-y
	


# n,m,q = input2()
# abcd=[]
# A=[0]*n
# for i in range(q):
# 	abcd.append(input_array())

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

for i in range(0,n,b):
	ans=fl(a,b,i)
	if ans> b_ans:
		b_ans=ans
	else:
		break
# if i<n:
# 	ans=fl(a,b,n)
# 	if ans> b_ans:
# 		b_ans=ans
print(b_ans)

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B > N:
    print(int(A*N/B) - A*int(N/B))
    exit()

else:
    print(max(int(A*N/B) - A*int(N/B),int(A*(N-1)/B) - A*int((N-1)/B),int(A*(B-1)/B) - A*int((B-1)/B)))

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-100000),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())
ans = []
cnt = 0

for i in reversed(range(N-B+1, N+1)):
    ans.append((A * i // B) - A * (i // B))
    cnt += 1
    if cnt >= 10:
        break

print(max(ans))

Submission status: Wrong Answer

Solution code:
A,B,N = (int(x) for x in input().split())
x = int(N/2)
ans = -1
length = int(N/4)
if(N <= 12):
    for i in range(N+1):
        if (int(A*i/B) - A*int(i/B)) > ans: 
             ans = (int(A*i/B) - A*int(i/B))
while(x > 2 and length > 2):
    ans1 = int(A*x/B) - A*int(x/B)
    ans2 = int(A*(x+1)/B) - A*int((x+1)/B)
    if(x == N):
        if(ans1 > ans):
            ans = ans1
        break
    elif(ans1 > ans2 and ans1 > ans):
        ans = ans1 
        x = ans -length
    elif(ans2 > ans1 and ans2 > ans):
        ans = ans2
        x = ans + length
    elif(ans1 > ans2 and ans1 <= ans):
        x = ans - length
    elif(ans1 < ans2 and ans2 <= ans):
        x = ans + length
    length = int(length/2)
for i in range(max(0,x-4*length),min(N,x+4*length)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
for i in range(min(6,N)):
    if (int(A*i/B) - A*int(i/B)) > ans:
        ans = (int(A*i/B) - A*int(i/B))
print(ans)

Submission status: Wrong Answer

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

temp = a * b // math.gcd(a, b) - 1
temp = min(temp, n - (n%b+1))
ans = (a * temp)//b - a * (temp//b)
print(ans)

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
    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())
ans = 0
m = math.floor(n-1000000)
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(1, 1000000):
        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:
A, B, N = map(int, input().split())

tmp = 0
a = 0
i = 0
if A < B:
    for i in range(B - 1, N + 1, B):
        if (s := (A * i) // B - A * (a)) > 0:
            tmp = max(s, tmp)
        else:
            break

if i >= N - B:
    for i in range(N, N - N % B - 1, -1):
        if (s := (A * i) // B - A * (i // B)) > 0:
            tmp = max(s, tmp)
        else:
            break

print(tmp)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    return max


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
x = math.gcd(A, B)
A = A / x
B = B / x
ans = 0
if (N <= (B - 1)):
  z = N
  p = (((A * z) / B) // 1)
  q = A * ((z / B) // 1)
  ans = p - q
elif (((N + 1) % B) == 0):
  z = N
  p = (((A * z) / B) // 1)
  q = A * ((z / B) // 1)
  ans = p - q
else:
  y = N // B
  z = y * B - 1
  p = (((A * z) / B) // 1)
  q = A * ((z / B) // 1)
  ans = p - q
print(int(ans))

Submission status: Wrong Answer

Solution code:

import math

val = input()

a = int(val.split(" ")[0])
b = int(val.split(" ")[1])
n = int(val.split(" ")[2])

print(a, b, n)

max = 0

for i in range(0, n+1):
    tar = math.floor(a*i/b) - a*math.floor(i/b)
    if tar > max:
        max = tar

print(max)

Submission status: Wrong Answer

Solution code:
A,B,N =map(int,input().split())
ans =0
i=1
while True:
    if int((A*i)/B)-A*int(i/B)!=0:
        if int((A*i)/B)-A*int(i/B) > ans:
            ans =int(A*i/B)-A*int(i/B)
            i+=1
        else:
            print(ans)
            break
    else:
        i+=1

Submission status: Wrong Answer

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

res = (A*N)//B - (A*(N//B))
print(res)

Submission status: Wrong Answer

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

if b > n :
    print(n)
else:
    max = 0
    for i in range(1,int(n)+1,1):
        r = (int(a)*i // int(b)) - (int(a)* (i//int(b)))
        if r > max:
            max = r

    print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x=[]
x.append(int(a*n/b)-a*int(n/b))
if n>b:
  t=int(n/b)
  x.append(int(a*(t*b-1)/b)-a*int((t*b-1)/b))
print(max(x))

Submission status: Wrong Answer

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

import math

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

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

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
if b>10**9:
	for i in range(10000000):
		cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	print(cnt)

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

# from math import floor

# 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:
    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 n>=b:
	n1 = 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())
maxn =0
if A<B:
    if B/2 <N:
        t = math.ceil(B/2)-1
        ans = tmp = math.floor((A*t)/B)-A*(math.floor(t/B))
    else:
        ans = tmp = math.floor((A*N)/B)-A*(math.floor(N/B))
else:
    for x in range(1,B+1):
        tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
        if maxn < tmp:
            maxn = tmp
    ans =maxn
print(ans)

Submission status: Wrong Answer

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

    print(y)
resolve()

Submission status: Wrong Answer

Solution code:
A,B,N = (int(i) for i in input().split())
l = []
m = []
for i in range(N):
    x = N
    c = int((A*x)/B)
    d = int(x/B)
    m.append(d)
    if m[i-1] > d:
        break
    e = c - d
    l.append(e)
print(max(l))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int, input().split())
ans = 0
for i in range(10**6):
    if i > N-1:
        break
    
    tmp = (A*(i+1))//B-A*((i+1)//B)
    if ans < tmp:
        ans = tmp
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 + 1:
    mid1 = (right * 2 + left) // 3
    mid2 = (right + left * 2) // 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
if f(right) >= f(left):
    print(f(right))
else:
    print(f(left))

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

# main()
print(main())

Submission status: Wrong Answer

Solution code:
def main():
    a,b,n = map(int,input().split())
    aa = min(b,n)
    ans = 0
    for i in range(aa,n):

        ans = max(ans,a*aa//b  - a * (aa//b))
    print(ans)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B-1:
    ans1 = int((A*(B-1))/B)-A*int((B-1)/B)
else:
    ans1 = ans
if N > 100000:
    p = N-100000
else:
    p = 1
for i in range(p, N+1):
    temp = int((A*i)/B)-A*int(i/B)
    if temp > ans:
        # print(i)
        ans = temp

print(max(ans, ans1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

max_ans=0
lis=[]
for x in reversed(range(N+1)):
        ans=math.floor(A*x/B)-(A*math.floor(x/B))
        if ans >= max_ans:
            max_ans=ans
        else:
            break
print(max_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC165c
last = 0


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)
    from math import floor
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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

    def evaluate(number):
        return floor(a*number/b)-a*floor(number/b)
        if number < 100:  # もっと高い値を探せ
            return 1
        if number == 100:  # まさにこの値
            return 0
        if number > 100:  # もっと低い値を探せ
            return - 1

    def binary_search(low, high):
        global last
        lowest = low
        highest = high
        while low < high:  # high-low >= 10**-12 ←これ以下の誤差を許容
            mid = (low + high) // 2
            left = (low + mid) // 2
            right = (mid+high)//2
            lv = evaluate(left)
            rv = evaluate(right)
            mv = evaluate(mid)
            #print(low, high)
            if lv < rv:
                last = max(mv, rv)
                low = mid
                lowest = mid
            else:
                last = max(mv, lv)
                high = mid
                highest = mid
            continue

            if guess == 0:
                return [mid, mid]
            if guess < 0:
                high = mid - 1  # 連続値の場合mid
                highest = mid
            else:
                low = mid + 1  # 連続値の場合mid
                lowest = mid

        return [lowest, highest]

    t = binary_search(0, n + 1)[0]
    #print(t, last)
    print(max(evaluate(max(0, t-2)), evaluate(max(0, t-1)), evaluate(min(n, t)),
              evaluate(min(n, t+1)), evaluate(min(n, t+2)), last))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

m = 0
num = int(b/a)+1
for i in range(1, b+1,num):
    if n < i:
        break
    a_part = int(a * i / b)
    b_part = a * int(i/b)

    result = a_part - b_part
    if m <= result:
        m = result
    else:
        break

print(m)

Submission status: Wrong Answer

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

ans = (A*N//B) - A*(N//B)
if N >= B:
    ans = max(ans, (A*B//B) - A*(B//B))
print(ans)

Submission status: Wrong Answer

Solution code:
import math 
s = input()
a = int(s.split(" ")[0])
b = int(s.split(" ")[1])
n = int(s.split(" ")[2])

def recur(frm,to):
    #print(frm,to)
    if to -frm <=1:
        return check(frm,to)

    half = math.floor((to - frm)/2)
    
    max_left = check(frm, frm + half)
    max_right = check(frm + half+1,to)

    #print("##")
    #print(frm, frm + half)
    #print(frm + half+1,to)
    #print("##end")

    if max_left >= max_right:
        return recur(frm,frm + half)
    else:
        return recur(frm + half+1,to)

def check(n1,n2):
    
    r1 = math.floor((a*n1)/b) - (a * math.floor(n1/b))
    r2 = math.floor((a*n2)/b) - (a * math.floor(n2/b))
    if r1 >= r2:
        return r1
    else:
        return r2
print(recur(0,n))