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
A, B, N = map(int, input().split())
t = N // B
if N % B == 0:
    a = max(1, N-1)
    b = N
else:
    a = max(1, t * B - 1)
    b = N

k = A * N // B
if A * N % B == 0:
    case = [a, b]
else:
    c = max(1,k*B//A)
    case = [a,b,c]

ans = 0
for i in case:
    ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

import math
M = 0
for x in range(max(N-1000,0),N+1):
    Z = math.floor(A * x / B) - A * math.floor(x / B)
    if M < Z:
        M = Z
print(M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def asahi(i):
  return int(a*i/b)-a*int(i/b)
c=asahi(0)
for k in range(n+1):
  c=max(c,asahi(k))

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)]
list = []

if N >= 100:
    for i in range(N-100,N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Wrong Answer

Solution code:
import math
from numba import jit

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


@jit
def run(A, B, N):
    x = 0
    ans1 = 0
    while x <= N and x <= 10**7:
        ans = int((A*x)/B) - A * int(x / B)
        ans1 = max(ans1, ans)
        x += 1
    return ans1


print(run(A, B, N))

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))
while True:
    if ans < 0:
        n-=1
        ans = (math.floor((a*n)/b) - a * math.floor(n/b))
    else:
        print(ans)
        break
#print(max(li))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

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

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

Submission status: Wrong Answer

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

ans1 = (a * n) // b;
ans2 = a * (n // b);
 
print(ans1 - ans2)

Submission status: Wrong Answer

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))
if N < 50:
    for i in range(1, N + 1):
        a = math.floor(((A * i) / B)) - A * math.floor((i / B))
        if res < a: res = a
else:
    for i in range(N - 50, N + 1):
        a = math.floor(((A * i) / B)) - A * math.floor((i / B))
        if res < a: res = a
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


nums = [int(e) for e in input().split()]

a = nums[0]
b = nums[1]
n = nums[2]

max_score = -1
score = -1
x = 1

while True:
    score = math.floor(a*x/b) - a* math.floor(x/b)
    if max_score < score:
        max_score = score
        x += 1
    else:
        break

print(max_score)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
answer=0
for i in reversed(range(0,N+1)):
    temp=math.floor(A*i/B)-A*math.floor(i/B)
    if answer>temp:
        answer=max(answer,temp)
        break
    else:
        
        answer=max(answer,temp)
    
print(answer)

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( min_num ) - func( max_num ) >= 0:
    min_num = a
  else:
    max_num = a
  if func( max_num ) == func( min_num ):
    break
 
print( func( a ))

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
ans=0
if B>=N:
    for i in range(0,10**6):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)
elif B<N:
    for i in range(0,10**5):
        x=N-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    for i in range(0,10**6):
        x=B-i
        if x<0:
            break
        tmp=int(A*x/B)-A*int(x/B)
        ans=max(ans,tmp)
    print(ans)

Submission status: Wrong Answer

Solution code:
import math

def bisearch(function, ok, ng):
    tmp = 0
    while abs(ok-ng) > 1:
        mid = (ok + ng)//2
        ans = function(mid)
        if ans > tmp:
            ok = mid
        else:
            ng = mid
        print("mid:{}".format(mid))
        tmp = ans
    return ok

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

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

# print(bisearch(calc, ok, ng))
ans = 0
for i in range(min(N+1, 10**8)):
    ans = max(calc(i), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
l=[]
m=a//b
if n>=b:
    for x in range(b-1,n):
        y=a*x//b-a*(x//b)
        #l.append(y)
        m=max(m,y)

else:
    x=n
    m=a*x//b-a*(x//b)
    #l.append(y)


print(m)

Submission status: Wrong Answer

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

import math
M = 0
for x in range(max(N-100,0),N+1):
    Z = math.floor(A * x / B) - A * math.floor(x / B)
    if M < Z:
        M = Z
print(M)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
ans=-100000000
a,b,n=map(int,input().split())
st=1
if n>=10000000:
    st=n-10000000
for i in range(st,n+1):
    keep=math.floor(a*i/b)-a*math.floor(i/b)
    if ans<keep:
        ans=keep
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def fn(x):
    return ((a*x)//b) - a*(x//b)
a,b,n = map(int, input().split())
ans = 0
if b <= n:
    ans = b
else:
    ans = n
print(fn(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = b - 1 if 0 <= b - 1 <= n else n - 1
print(a*x//b - a * (x // b))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
ans=int((n*a)//b)-(a*int(n//b))
for i in range(n-1,0,-1):
  tmp=int((i*a)//b)-(a*int(i//b))
  if ans>tmp:
    break
  else:
    ans=tmp
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
a,b,n = map(int,input().strip().split())
f = 0
if a<b:
    a,b = b,a
    f = 1
s = 1
e = n
maxi = 0
while s<=e:
    x = (s+e)//2
    if not f:
        check = floor((a * x) / b) - a * floor(x / b)
    else:
        check = floor((b * x) / a) - b * floor(x / a)
    if check > maxi:
        maxi = check
        s = x+1
    else:
        e = x-1
print(maxi)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math
def func(x,a,b):
    return math.floor((a*x)/b)-a*math.floor(x/b)
a,b,n=map(int,input().split())
mx=0
st=b-1
i=0
j=n 
while(i<=j):
    mid=(i+j)/2
    xx=func(mid,a,b)
    yy=func(mid-1,a,b)
    if (xx>mx):
        mx=xx
    if xx>=yy:
        i=mid+1
    else:
        j=mid-1
    
print(mx)

Submission status: Wrong Answer

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

if b == 1 or a == 1:
    print(0)
    exit()
if n//b < 1:
    print((a*n)//b)
else:
    print(a-1)

Submission status: Wrong Answer

Solution code:
'''
def floor(x, y):
    return(x // y)
'''
lis = input().split()

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

x = 0
MAX = 0
MAXX = 0

'''
while(x <= N):
    x += 1
    MAXX = MAX
    f = floor(A*x, B)
    b = A * floor(x, B)
    MAX = f - b
    #print(MAX, MAXX, "2")
'''

while(x <= N):
    x += 1
    MAXX = MAX
    f = (A*x) // B
    b = A*(x // B)
    MAX = f - b
    #print(MAX, MAXX, "2")


print(MAXX)

Submission status: Wrong Answer

Solution code:
inp = input().split(" ")
a = int(inp[0])
b = int(inp[1])
n = int(inp[2])
y = - 10 ** 10
for x in range(10):
    z = int(a*(n-x)/b) - a*int((n-x)/b)
    if y < z:
        y = z
print(y)

Submission status: Wrong Answer

Solution code:
import math

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

solved_flag = False
if B==1:
    ans = 0
    solved_flag = True
else:
    if B < N:
        x = B-1
    else:
        x = N

if not solved_flag:
    ans = math.floor(A*x/B) - A*math.floor(x/B)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def floor_t(A,B,y):
    return math.floor(A*y/B) - A*math.floor(y/B)

total = 0


for x in range(B//2,N+1):
    if x%B==0:
        continue
    else:
        total = max(total,floor_t(A,B,x))

print(total)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
a, b, n = map(int, input().split())
if n > b:
    print(math.floor((a * (b - 1)) / b) - a * math.floor((b - 1) / b))
else:
    print(math.floor((a * n / b) - a * math.floor(n / b)))

Submission status: Wrong Answer

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


A, B, N = map(int, input().split())
print(max(calc(N), calc(N-1)))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int,input().split())
fivex = 0
i = 1
ans = 0
x = 0
ans_x = -((-1)*A*N // B)
if ans_x>N:
    ans_x -= 1
# print(ans_x)
print(int(A*ans_x/B)-A*int(ans_x/B))
# while x <= N:
#     x = -((-1)*i*B // A)
#     if x > N:
#         break
#     now = i - A *  int(x / B)
#     if now > ans and x <= N:
#         print(x)
#         ans = now
#     i += 1

# print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    a,b,n=map(int,input().split())
    def fl(a,b,x):
        return int(a*x/b)-a*int(x/b)
    x=n
    pretemp=fl(a,b,x)
    prex=0
    nowmax=n
    nowmin=0
    dis=n//2
    if dis<=0:
        dis=1
    i=1
    right=False
    while i<=500000:
        if i%50==0:
            dis=-(dis//(-2))
        if right:
            x+=dis
            if x>n:
                x=n
            temp=fl(a,b,x)
        else:
            x-=dis
            if x<0:
                x=0
            temp=fl(a,b,x)
        if temp>=pretemp:
            pass
        elif temp<pretemp:
            right=(right-1)*(-1)
        pretemp=temp
        i+=1
    if x+1<=n:
        tempup=fl(a,b,x+1)
    else:
        tempup=fl(a,b,x)
    if x-1>=0:
        templow=fl(a,b,x-1)
    else:
        templow=fl(a,b,x)
    temp=fl(a,b,x)
    temp=max(temp,templow,tempup)

    print(temp)


if __name__ == "__main__":

    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

A,B,N=map(int,input().split())
C=[0]
z=0

for x in range(1,N+1):
  y=math.floor((A*x)/B)+A*math.floor(x/B)
  C.append(y)
  z=max(z,y)

print(z)

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, gcd
from itertools import accumulate, permutations, combinations, product, groupby
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()

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

ans = -INF
for i in range(1, min(2*(A+1), N+1)):
	ans = max(ans, f(i))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n<=b:
	res=f(a,b,n)
	print(res)
else:
	res=f(a,b,b-1)
	if n%b==0:
		res=max(res,f(a,b,n-1))
		print(res)
	else:
		res=max(res,f(a,b,(n//b)-1))
		print(res)

Submission status: Wrong Answer

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

if N >= B-1:
    print(A-(A%B+1))
else:
    print(math.floor(A*N/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:
import math
A,B,N = map(int,input().split())
x = math.gcd(N,B)
K = math.floor(N/B)
if K == 0:
    print(math.floor(A*N/B)-A*math.floor(N/B))
else:
    alpha = B*(K+1)-1
    if alpha > N:
        alpha = N
    print(math.floor(alpha/B)-A*math.floor(alpha/B))

Submission status: Wrong Answer

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

ans = (A*N)//B - A*(N//B)

print(ans)

Submission status: Wrong Answer

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


def solve(A: int, B: int, N: int):
    if B >= N:
        x = N
    else:
        x = B - 1
    print(A * x // 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())
result = 0

x = N
for a in range(1, A):
    if int(x/B + a/A) > int(x/B):
        result += 1

print(result)

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

    res = 0

    for i in range(N-A, N+1):
        if i >= 1:
            res = max(res, func(i))
    
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import math
from collections import Counter
a,b,n=map(int,input().split())
if a>b:
	a,b=b,a
if n<=a:
	print((a*n)//b-a*(n//b))
elif n>a and n<b:
	print((a*n)//b-a*(n//b))
else:
	n=b-1
	print((a*n)//b-a*(n//b))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
p = 1
ans = [0]
if n <= b:
    print(a*n//b)
else:
    while p*b < n:
        ans.append(a*(((p+1)*b-1)//b)-p)
        p += 1
    print(max(ans))

Submission status: Wrong Answer

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

A, B, N = list(map(int,input().split()))
x1 = []
c = 0
while 1:
    c += 1
    ret = int((B * c) / A)
    if ret > N:
        break
    x1.append(ret) 
length = len(x1)
ans = 0
for i in range(length):
    ans = max(ans, i + f(x1[i]))
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 == 100000000:
    break
print(mx)

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( min_num ) - func( max_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:
a,b,n = map(int, input().split())
#1 <= x <= n
#minimize  int(x/b)
#x = int(a*x/b) - a * int(x/b)
 
print((a*n)//b)

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)]
list = []

if N >= 30:
    for i in range(N-30,N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Wrong Answer

Solution code:
from math import floor


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


def main():
    a, b, n = map(int, input().split())
    answer = [0 for _ in range(2 * (min(a, b)) + 1)]
    for i in range(1, 2 * min(a, b) + 1):
        answer[i] = f(i, a, b)
    if n <= min(a, b):
        print(max(answer[:n + 1]))
    else:
        print(max(answer))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
def val(x):
  global a, b, n
  return int((a*x)//b - a*(x//b))

if n >= b:
  print(val(b-0.001))
else:
  print(val(n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if N < B:
    if N % B == 0:
        x = N-1
    else:
        x = N
        ans = math.modf((N/B))[0]*A

else:
    if N % B == 0:
        x = (N-1)%B
    else:
        x = N%B

ans = math.modf((x/B))[0]*A
print(int(ans))

Submission status: Wrong Answer

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

trial = (A*N)//B
ans = 0
#temp = 0
for i in range(1, trial):
    if ans < i - (A * (i // A) - 1):
        ans = i - (A * (i // A) - 1)
        #temp = i
print(ans)

Submission status: Wrong Answer

Solution code:
import math
from numba import jit

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


@jit
def run(A, B, N):
    x = 0
    ans1 = 0
    while x <= N and x <= 5*10**6:
        ans = int((A*x)/B) - A * int(x / B)
        ans1 = max(ans1, ans)
        x += 1
    return ans1


print(run(A, B, N))

Submission status: Wrong Answer

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

for n in range(B-1, 0, -1):
    nB = n/B - floor(n/B)
    AnB = A * nB

    AnBf = floor(A*n/B) - A*n/B
    print(floor(A*n/B)-A*floor(n/B))
    exit()

Submission status: Wrong Answer

Solution code:
A,B,N=list(map(int,input().split()))
list_ans=[]
for i in range(N-2,N+1):
  list_ans.append(int(A*i/B)-A*int(i/B))
print(int(max(list_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

# main()
print(main())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:55:57 2020

@author: Kanaru Sato
"""

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

if a*b <= n*a + b:
    print(a-1)
else:
    u = int((a*n)/b)
    v = a*int(n/b)
    print(u-v)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
(A,B,N) = map(int,input().split())
start = int(A*N/B)-A*int(N/B)
startx = int(N/B)
flag = 0
for i in reversed(range(1,startx)):

    subans = (int(A*(B*i-1)/B)-A*int((B*i-1)/B))
    if subans <= start:
        flag += 1
    else:
        start = subans
        flag = 0

    if flag == 2:
        break

print(start)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

lo = 1
hi = N
ans = 0
if B-1<=N:
    ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

max_k = calc(a,b,n)

for i in range(1,n+1):
    if i*b > n:
        if i==1:
            break
        k = calc(a,b,(i-1)*b-1)
        print(i)
        if max_k < k:
            max_k = k
            break
        
print(max_k)

Submission status: Wrong Answer

Solution code:
def bs(l,c,r):

  #print(l,c,r)

  if l>=r:
    print(int(a*c/b)-a*int(c/b))
    return

  w1=int(a*(c-1)/b)-a*int((c-1)/b)

  w=int(a*c/b)-a*int(c/b)

  w2=int(a*(c+1)/b)-a*int((c+1)/b)

  #print("w",w1,w,w2)

  if (r-l)<3:
    if w1<w2:
      print(w2)
      return 
    else:
      print(w1)
      return 

  if w1>w and w>w2:
    bs(l,int((l+c)/2),c)
  
  elif w1<w and w<w2:
    bs(c,int((r+c)/2),r)

  elif w1==w:
    print(w)
    return
  elif w==w2:
    print(w)
    return 

  return 0

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

bs(0,int(n/2),n)

Submission status: Wrong Answer

Solution code:
import math
A,B,N =  map(int,input().split())
ans = 0
before = 0
for x in range(1,N+1):
    if math.floor(A*x/B)-A*math.floor(x/B)<before:
        ans = before
        break
    elif x == N:
        ans = math.floor(A*x/B)-A*math.floor(x/B)
        break
print(ans)

Submission status: Wrong Answer

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

ans = 0
if N == max(A, B, N):
    ans = (A*N//B)-A*(N//B)
else:
    if N <= 1000000:
        for x in range(1, N+1):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(1, 300000):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)

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

        for x in range(N-300000, N):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
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 == 10000000:
    break
print(mx)

Submission status: Wrong Answer

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


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

    if n < b:
        return (a * n) // b

    return 0


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def fl(i):
  return ((A * i) // B) - (A * (i // B))

i = 1
j = [0, N]
while i > 0:
  s = fl(j[0])
  t = fl(j[1])
  if t > s:
    j[0] = (j[1] - j[0]) / 2 + j[0]
  else:
    j[1] = (j[1] - j[0]) / 2 + j[0]
  if j[1] - j[0] < 0.1:
    break

x = int(fl(j[0] // 1))
y = int(fl(j[1] // 1))
z = int(fl(j[1] // 1 + 1))
print(max(x, y, z))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
a = A//B
k = A%B
n = N//B

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

print(max(a*(B-1)-k-1, f(N)) if n>0 else f(N))

Submission status: Wrong Answer

Solution code:
import math

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

x = math.ceil(B-1.0*B/A)

if N <= x:
    ans = math.floor(1.0*A*N/B) - A*math.floor(1.0*N/B)
    print(ans)
else:
    ans2 = math.floor(1.0*A*x/B) - A*math.floor(1.0*x/B)
    print(ans2)

Submission status: Wrong Answer

Solution code:
import math


A, B, N = map(lambda x: int(x), input().split(" "))

result = 0
candidate = -1
for i in reversed(range(0, N+1, B)):
    if i % B == 0:
        candidate= i-1
        break

if candidate > 0:
    i = candidate
    temp = math.floor(A*i/B) - A*math.floor(i/B)
    result = max(result, temp)

temp = math.floor(A*N/B) - A*math.floor(N/B)
result = max(result, temp)

print(result)

Submission status: Wrong Answer

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

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, B+1):
        if max < a(A,B,x):
            max = a(A,B,x)
    
    print(max)



    


if __name__ == "__main__":
	main()