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 math


def solve():
    A, B, N = map(float, input().split())
    ans = 0
    div_ab = A/B
    div_1b = 1/B
    now_1 = (max(1, int(N)-5000)*A)/B
    now_2 = max(1, int(N)-5000)/B

    for i in range(max(1, int(N)-5000), int(N) + 1):
        ans = max(math.floor(now_1) - A*math.floor(now_2),ans)
        now_1 += div_ab
        now_2 += div_1b
        

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import math

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

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

if b < n:
    print(f(a, b, b-1))
else:
    print(f(a, b, n))

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
c = 0
for x in range(N+1, 1, -1):
    a = math.floor(A*x/B) - A * math.floor(x/B)
    if a > c:
        c = a
        break
    c = a
print(c)

Submission status: Wrong Answer

Solution code:
import sys


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


ans = b-1



print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
start=1
end=n
ans=0
while start<=end:
	mid=(start)+(end-start)//2
	ans1=math.floor((a*mid)/b)-(a*math.floor(mid/b))
	ans2=math.floor((a*start)/b)-(a*math.floor(start/b))
	ans3=math.floor((a*end)/b)-(a*math.floor(end/b))
	ans=max(ans,ans1)
	ans=max(ans,ans2)
	ans=max(ans,ans3)
	if ans2<=ans3:
		start=mid+1
	else:
		end=mid-1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
line = input()
a, b, n = line.split(" ")
a, b, n = int(a), int(b), int(n)
ans = 0
# for i in range(n+1):
#     ans = math.floor((a*i)/b) - math.floor(i/b)
#     print(ans)

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

Submission status: Wrong Answer

Solution code:
# map(int,input().split())
# int(input())
import math
a,b,c = map(int,input().split())
# if a< b 定まらん
# if a>=b a-1
# cの値による？c <= a-2 のとき.
maxcnt = 0
if a<b:
	for x in range(min(c+1, a-1)):
		cnt = math.floor(a*x/b) - a* math.floor(x/b)
		if cnt > maxcnt:
			maxcnt = cnt
else:
	if c <= a-2:
		for x in range(c + 1):
			cnt = math.floor(a * x / b) - a * math.floor(x / b)
			if cnt > maxcnt:
				maxcnt = cnt
	else:
		x = a-1
		maxcnt = math.floor(a * x / b) - a * math.floor(x / b)
print(maxcnt)

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)
    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 sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

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

print(m)

Submission status: Wrong Answer

Solution code:
ABN = [int(x) for x in input().split()]
y=0
n=[]
for i in range(1,int((ABN[2]+1)/ABN[1])+1):
  n.append(ABN[1]*i-1)
for x in n:
  if y<int(ABN[0]*x/ABN[1])-ABN[0]*int(x/ABN[1]):
    y=int(ABN[0]*x/ABN[1])-ABN[0]*int(x/ABN[1])
  
print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import *
A,B,N=[int(i) for i in input().split()]
f=lambda x:floor(A*x/B)-A*floor(x/B)
print(f(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

a,b,n=map(int,input().split())
maxtemp=0
teisuu=100000
def funcsum(x):

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

for i in range(n):
    if i>teisuu:
        break
    temp=n-i
    maxtemp=max(maxtemp,funcsum(n-i))
print(maxtemp)

#items=[int(i) for i in input().split()]


#items=[i for i in range(n+1)]

Submission status: Wrong Answer

Solution code:
import math
ans=0
a,b,n=map(int,input().split())
st=1
if n>10000001:
    st=n-a
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:
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
while True:
    c = calc(A,B,x)
    if ans >= c:
        break
    else:
        ans = c
    x+=1
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

def check(x):
    return int(a*x/b)-a*int(x/b)
    
preans=0
for i in range(n,0,-1):
    ans=check(i)
    if(ans<preans):
        break
    preans=ans
print(preans)

Submission status: Wrong Answer

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

x = min(b - 1, n)
v1 = floor(a * x / b) - a * floor(x / b)
x = n
v2 = floor(a * x / b) - a * floor(x / b)
print(max(v1, v2))

Submission status: Wrong Answer

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

ans = [(a*i//b) - a*(i//b) for i in range(1, b+1)]

print(max(ans))

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
a = s[0]
b = s[1]
n = s[2]

kotae = round(a * ((n / b) - (n // b)) - ((a * n / b) - ((a * n) // b)))

print(kotae)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
if B==1:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

print((min(N-1,B))*A//B)

Submission status: Wrong Answer

Solution code:
import math
a, b, n = map(int, input().split())
ma = -1
for x in range(n, -1, -1):
    tmp = math.floor(a*x/b) - a*math.floor(x/b)
    if x != n:
        if pre > tmp:
            break
    if ma < tmp:
        ma = tmp
    pre = tmp
print(ma)

Submission status: Wrong Answer

Solution code:
#D
a,b,n = map(int,input().split())
x = n
ans1 = ((a*x)//b) - (a*(x//b))
x = n-1
ans2 = ((a*x)//b) - (a*(x//b))
x = n-b
ans3 = ((a*x)//b) - (a*(x//b))
x = n//b
ans4 = ((a*x)//b) - (a*(x//b))
x = n//2
ans5 = ((a*x)//b) - (a*(x//b))
x = 1
ans6 = ((a*x)//b) - (a*(x//b))
print(max(ans1,ans2,ans3,ans4,ans5,ans6))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N = (int(x) for x in input().split())
x = N/2
ans = -1
length = int(N/4)
while(x > 2):
    ans1 = int(A*x/B) - A*int(x/B)
    ans2 = int(A*(x+1)/B) - A*int((x+1)/B)
    if(x == N):
        break
    elif(ans1 > ans2 and ans1 > ans):
        ans = ans1 
        x = ans -length
    elif(ans2 > ans1 and ans2 > ans):
        ans = ans2
        x = ans + length
    else: 
        break
    length = int(length/2)
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() )
 
min_num = 1
max_num = N
 
def func( x ):
  return math.floor( A * x / B ) - A * math.floor( x / B )
  
ret = 0
while True:
  a = math.ceil( ( max_num + min_num ) / 2 )
  if func( max_num ) - func( min_num ):
    min_num = a
  else:
    max_num = a
  if func( max_num ) == func( min_num ):
    break

print( func( a ))

Submission status: Wrong Answer

Solution code:
def main():
    A, B, N = list(map(int, input().split(' ')))
    N %= B
    print(int(A * N / B))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

a, b, n = list(map(int, input().split()))
max_k = 0
cnt=0

for x in range(n,0,-1):
    k = math.floor(a*x/b) - a*math.floor(x/b)
    if max_k < k:
        max_k = k
    
    cnt += 1
    if cnt>=b:
        break

print(max_k)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split(" "))
max_floor = 0
for x in range(N+1):
  floor_x = int(A*x/B) -A*int(x/B)
  if max_floor < floor_x:
    max_floor = floor_x
print(floor_x)

Submission status: Wrong Answer

Solution code:
from math import gcd

a,b,n=map(int,input().split())
t=a*b//gcd(a,b)

ans=[]

for i in range(1,t+1):
    y=int(a*i/b)-a*int(i/b)
    ans.append(y)

n%=t
ans=ans[:t]
print(max(ans))

Submission status: Wrong Answer

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

def func(x):
    return int(A * x * B ** -1) - A * int(x * B ** -1)

ub = N
lb = 0
obj = func(N)
ans = [func(N)]
while ub - lb > 1:
    mid = (ub + lb) // 2
    v = func(mid)
    if obj < v:
        lb = mid
        ans.append(v)
    else:
        ub = mid

print(max(ans))

Submission status: Wrong Answer

Solution code:

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


dammy = (A*N)//B - A * int(N/B)

print(dammy)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, N = MAP()

x = N
ans = (A * x//B) - A * (x // B)
print(ans)
exit()
for x in range(N + 1):
    ans = (A * x//B) - A * (x // B)
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if B>=A:
    x=0
    ans=0
    y=0
    while(x<=N):
        ans=max(ans,((A*x)//B)-A*(x//B))
        y+=1
        x=(B*y)//A
    print(ans)
else:
    ans=0
    for x in range(1,min(B+1,N+1)):
        ans=max(ans,((A*x)//B)-A*(x//B))
    print(ans)

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n, max(-1, n - a*10 - 1), -1):
    ans = max(ans, a * x // b - a * (x // b))

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
ans=0
a,b,n=map(int,input().split())
st=1
if n>1000001:
    st=n-a
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 = tuple(map(int, input().split()))

ans = 0
for x in range(max(min(n-a, n-b), 0), n+1):
    tmp = math.floor((a*x)/b) - (a * math.floor(x/b))
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n = list(map(int,input().split()))
x = 1
temp = 0
res = 0

for i in range(n):
    temp = math.floor((a*x)/b) - a * math.floor(x/b)
    if res < temp:
        res = temp
    x += 1
    if x == 10:
        break

print(res)

Submission status: Wrong Answer

Solution code:
import math

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

a_1 = A / B
b_1 = 1 / B
lis = []

for i in range(1,N+1):
    a_2 = math.floor(a_1*i)
    b_2 = math.floor(b_1*i)
    lis.append(a_2 - b_2)
    
print(max(lis))

Submission status: Wrong Answer

Solution code:
import math
ABN=input().split()
A=int(ABN[0])
B=int(ABN[1])
N=int(ABN[2])
max=0
for i in range(1,N+1):
    tmp=math.floor(i/B)*(math.floor(A)-A)
    if(tmp>max):
        max=tmp
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  A, B, N = (int(_) for _ in input().split())
  k = A * N // B
  if k >= A - 1: print(A - 1)
  else:
    print(k)
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

for i in range(N,N-B,-1):
  x = i+1
  Y = int(float(A)*float(x)/float(B)) - A * int(float(x)/float(B))
  if Y>Ymax:
    Ymax = Y
print(Ymax)

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:
import math
a,b,n=map(int,input().split())

def judge(x):
  if math.floor(a*x/b)-math.floor(a*(x-1)/b)>a*(math.floor(x/b)-math.floor(x-1/b)):
    return True 
  else:
    return False

def bi_re():
  l=1
  r=n
  
  while l<=r:
    m=(l+r)//2
    if judge(m):
      l=m+1
    else:
      r=m-1
  return m
c=bi_re()
#print(c)
print(math.floor(a*c/b)-a*math.floor(c/b))

Submission status: Wrong Answer

Solution code:
a , b , n = map(int , input().split())
l = 0
r = n
ans = 0
while (l < r) :
    mid = (l + r + 1) // 2
    if  (a * mid) / b - a * (mid / b) >= ans :
         l = mid
    else :
        r = mid - 1
print((a * r) // b - a * (r // b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c=[]

for x in range(n+1):

    c.append(int(a*x/b)-int(x/b))

print(max(c))

Submission status: Wrong Answer

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

# if a < b:
#     tmp =

for x in range(1, b):
    tmp = math.floor((a*x) / b) - a * math.floor(x/b)
    if tmp > max:
        max = tmp

print(max)

Submission status: Wrong Answer

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

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

    M = 0
    for i in range(N, max(0, N - 10 ** 6 - 100), -1):
        tmp = func(i)
        if tmp > M:
            M = tmp

    print(M)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
c = 0
for x in range(N+1, 1, -1):
    a = math.floor(A*x/B) - A * math.floor(x/B)
    if a < c:
        break
    c = a
print(c)

Submission status: Wrong Answer

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

max_v = 0
for x in range(0, min(B+1, N+1), min(B, N)):
    v = math.floor(A*x/B) - A*math.floor(x/B)
    if max_v < v:
        max_v = v
print(max_v)

Submission status: Wrong Answer

Solution code:
import math


def solve():
    A, B, N = map(float, input().split())
    ans = 0
    div_ab = A/B
    div_1b = 1/B
    now_1 = (max(1, int(N)-100)*A)/B
    now_2 = max(1, int(N)-100)/B

    for i in range(max(1, int(N)-5000), int(N) + 1):
        ans = max(math.floor(now_1) - A*math.floor(now_2),ans)
        now_1 += div_ab
        now_2 += div_1b

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A,B,N =map(int,input().split())
ans = 0
for i in range(N,N -B -1,-1):
        ans =max(ans,floor(A,B,i))
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

resN = N % B

print(A * resN // B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1,n+1):
  x = int(a*i/b) - a*int(i/b) #これの最大値？
  if x > ans:
    ans = x'''

if n%b == 0 and (a*n)%b == 0: #どちらの余りも0だったら
  print(int(a*(n-1)/b) - a*int((n-1)/b))
else:
  print(int(a*n/b) - a*int(n/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def judge(mid):
    if mid == 0:
        return True
    if (a*mid//b) - (a*(mid//b)) > (a*(mid-1)//b) - (a*((mid-1)//b)):
        return True
    else:
        return False

if judge(n):
    print((a*n//b) - (a*(n//b)))
    sys.exit()


left = 0
right = n

while right - left > 1:
    mid = (right + left) // 2
    if judge(mid):
        left = mid
    else:
        right = mid

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print((min(N,B)-1)*A//B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

print(max(ans))

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int, input().split())
m = A//B
a = A%B
x = N%B
print(m*x+floor(a*x/B))

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
c = 0
for x in range(N, 1, -1):
    a = math.floor(A*x/B) - A * math.floor(x/B)
    if a < c:
        break
    c = a
print(c)

Submission status: Wrong Answer

Solution code:
import math


def solve():
    A, B, N = map(float, input().split())
    ans = 0
    div_ab = A/B
    div_1b = 1/B
    now_1 = (max(1, int(N)-100)*A)/B
    now_2 = max(1, int(N)-100)/B

    for i in range(max(1, int(N)-100), int(N) + 1):
        ans = max(math.floor(now_1) - A*math.floor(now_2),ans)
        now_1 += div_ab
        now_2 += div_1b

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
import math

if __name__ == '__main__':
    a, b, n = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    # for x in range(n+1):
    #     print(math.floor(a*x/b)-a*math.floor(x/b))

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

Submission status: Wrong Answer

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

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

ans = 0

for x in range(n,max(1,n-3 * 10**6),-1):
    ans = max(ans,f(x))
    
print(ans)

Submission status: Wrong Answer

Solution code:
# abc165_d.py
from math import floor
A, B,N = map(int,input().split())
ans = -100000000
for i in range(1,A):
    t = floor(A*i/B)-A*floor(i/B)
#    print(i, t,floor(A*i/B),A*floor(i/B))
    if ans<=t:
        ans = t
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

high = n
low = 0
while high - low >= 0.01:
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) <= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(f(int(high)))

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if B==1:
    print(0)
    exit()

if N==1:
    ans=(A//B)-A*(1//B)
    print(ans)
    exit()
if A==1:
    print(0)
    exit()
    
if B<N:
    val=B-1
    ans=(A*val)//B
else:
    val=N
    ans=(A*val)//B

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N,N-B,-1):
  x = i+1
  Y = int(float(A)*float(x)/float(B)) - A * int(float(x)/float(B))
  if Y>Ymax:
    Ymax = Y
  print(x)
print(Ymax)

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

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

#print(x)

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

#print(a,b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


A, B, N = map(int, input().split())
ans = 0
ans_before = 0
ans_list = []
for i in range(N+1):
  ans = math.floor(A*i/B)-A*math.floor(i/B)
  #print(ans_before,ans)
  if(ans_before<=ans):
    ans_before = ans
  #print("ans",ans)
  
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]

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

Submission status: Wrong Answer

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

r = N

print(int(A*r/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
k = 0

while True:
    x = B / A * k
    if x > N: break
    ans = max(A * x // B - A * (x // B), ans)
    k += 1

print(int(ans))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
def D():
    A, B, N = map(int, input().split())
    if N >= B:
        print(A-1)
        return
    x = N % B
    print(A*x//B - A*(x//B))
D()

Submission status: Wrong Answer

Solution code:
from math import floor


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


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

left,right=0,n
while right>left+10**-11:
    mid1=(right*2+left)/3
    mid2=(right+left*2)/3
    if f(mid2)>f(mid1):right=mid1
    else:left=mid2

print(f(left))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


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


a, b, n = sp()
low, high = 1, n
answer, index = -inf, 0
while low <= high:
    mid = (low + high) // 2
    temp = calc(mid)
    if temp > answer:
        answer = temp
        low = mid + 1
    else:
        high = mid - 1
out(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

ans = 0

for x in range(n,max(1,n-2 * 10**6),-1):
    ans = max(ans,f(x))
    
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
A,B,N = map(int, input().split())
m = A//B
a = A%B
print(m*N+floor(a*N/B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if B>N:
    B=N-1

print(int(A*B/N) - int(B/N)*A)

Submission status: Wrong Answer

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

ans = max([func(i) for i in range(min(N+1, A+1))])

print(ans)

Submission status: Wrong Answer

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

for i in range(1000000):
    x=(hi+low)//2
    t0=floor(a*x/b)-a*floor(x/b)
    t1=floor(a*(x+1)/b)-a*floor((x+1)/b)
    if t1>=t0:
        low=x
    else:
        hi=x+1

ans=0
for i in range(10):
    z=x-5+i
    if 0<=z<=n:
        t=floor(a*z/b)-a*floor(z/b)
        ans=max(t,ans)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for x in range(0,N+1):
  a=math.floor(A*x/B)-A*math.floor(x/B)
  if(res<a):
    t=a
    res=x

print(res)

Submission status: Wrong Answer

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

ans = -float("inf")
for x in range(n, max(-1, n - a - 2), -1):
    ans = max(ans, a * x // b - a * (x // b))

print(int(ans))

Submission status: Wrong Answer

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

def floor(x):
    num = int(x // 1)
    return num

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

Submission status: Wrong Answer

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

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

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

    # 終了判定
    if ans == B-1:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
#D
a,b,n = map(int,input().split())
x = n
ans1 = ((a*x)//b) - (a*(x//b))
x = n-1
ans2 = ((a*x)//b) - (a*(x//b))
x = n-b
ans3 = ((a*x)//b) - (a*(x//b))
x = n//b
ans4 = ((a*x)//b) - (a*(x//b))
print(max(ans1,ans2,ans3,ans4))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
val = a*n//b
for i in range(max(0,n//b - a), n//b):
    m = b*i - 1
    if (m > n) or (m < 0):
        continue
    else:
        val = max(val, (m*a)//b - i)
for i in range(max(0,n//b - a), n//b):
    m = b*i - 1
    if (m > n) or (m < 0):
        continue
    else:
        val = max(val, (m*a)//b - i)
        
print(val)