Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

Find the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.

Here floor(t) denotes the greatest integer not greater than the real number t.

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

Print the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N, as an integer.

Sample Input 1

5 7 4

Sample Output 1

2

When x=3, floor(Ax/B)-A×floor(x/B) = floor(15/7) - 5×floor(3/7) = 2. This is the maximum value possible.

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
#import sys
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
    i=1
    right=False
    while i<=100000:
        if i%10==0:
            dis=-(dis//(-2))
        if right:
            x+=dis
            if x>n:
                x=n-dis//2
            temp=fl(a,b,x)
        else:
            x-=dis
            if x<0:
                x=dis//2
            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:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    # import random

    a, b, n = map(int, input().split())
    # a = random.randint(1, 10**6)
    # b  = random.randint(1, 10**12)
    # n = random.randint(1, 10**12)
    if b > n:
        print(int(math.floor(a*n/b)-a*math.floor(n/b)))
        exit()

    if b >= 10**6:
        ans = int(math.floor(a*n/b)-a*math.floor(n/b))
        for i in range(b-1, n+1, b):
            temp =  math.floor(a*i/b)-a*math.floor(i/b)
            if ans < temp:
                ans = temp
        print(int(ans))
        exit()

    ans = int(math.floor(a*n/b)-a*math.floor(n/b))
    i = math.floor(n/b)*b-1
    for _ in range(2*10**6):
        temp =  math.floor(a*i/b)-a*math.floor(i/b)
        if ans < temp:
            ans = temp
        i -= b
        if i <= 0:
            print(int(ans))
            exit()
    print(int(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 <= 10000000:
        for x in range(1, N+1):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
    else:
        for x in range(N-10000000, N):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(max(int(ans), 0))

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    A,B,N = map(int, input().split())
    nax = -10
    for i in range(min(A,N)+1):
        ans = floor(A*i/ B) - A * (floor(i/B))
        nax = max(nax,ans)
    print(nax)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
l = input().split()
a = int(l[0])
b = int(l[1])
n = int(l[2])
max = 0
calc = 0
for i in range(1, n+1):
  calc = math.floor(a*i / b) - a * math.floor(i/b)
  if max < calc:
    max = calc
print(calc)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if B >= N:
    print(f(N))
else:
    print(max(f(B), f(B-1)))

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*n)//b)-a*(n//b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(1,k):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    a,b,n  = map(int, input().split())
    maemax=math.floor(a*n/b)
    ushiromax=math.floor(n/b)
    i=n
    j=n
    while i*n/b>=maemax:
        if i*n/b>=maemax:
            i-=1
        else:
            break
    while j*n*a/b>=ushiromax:
        if j*a*n/b>=ushiromax:
            j-=1
        else:
            break
    if j<=i:
        print(maemax-ushiromax)
    else:
        print(math.floor(j*a/b)-mathfloor(j/b))
resolve()

Submission status: Wrong Answer

Solution code:
arr = input().split(" ")
a, b, n = int(arr[0]), int(arr[1]), int(arr[2])
if b<=n:
  k = a
else:
  k = (a*n)//b
print(k)

Submission status: Wrong Answer

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

tmp = 0
a = 0
for i in range(B - 1, N + 1, B):
    if (s := (A * i) // B - A * a) > tmp:
        a += 1
    else:
        break
    
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:
def f(a,b,x):
	return (a*x)//b - a*(x//b)
	
a,b,n=map(int,input().split())
if n<=b:
	print(f(a,b,n))
else:
	print(f(a,b,b-1))

Submission status: Wrong Answer

Solution code:
#!python3

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


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


def main():
    if N < B:
        ans = f(N)
        print(ans)
        return
    
    l = []
    l.append(f(B - 1))
    l.append(f(N) if N % B != 0 else f(N - 1))
    l.append(f(N // B * B - 1))
    l.append(f(N))

    ans = max(l)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
A,B,N=map(int,input().split())
A=float(A)
B=float(B)
maxi=0
for x in range(N):
    x=float(x)
    if math.floor(A*x/B)-A*math.floor(x/B) >=maxi:
        maxi = math.floor(A*x/B)-A*math.floor(x/B)
print(int(maxi))

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(min(b, n), 0, -1):
    score = math.floor((a*x)/b) - math.floor(a*(x//b))
    if (score > 0):
        print(score)
        break

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//b*b-1
if x<0:
    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())

x=0
pre=floor(A*x/B)-A*floor(x/B)
max_x=0
max_i=pre

while True:
	x +=1
	cur=floor(A*x/B)-A*floor(x/B)
	#print(pre, cur)
	if (cur < pre)and(x<=N):
		print(x-1)
		break
	elif(x>N):
		print(max_x)
		break
	else:
		if max_i < cur:
			max_i = cur
			max_x = x
		pre = cur

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = 0
    for i in range(min(N, B), 1, -1):
        tmp = (A * i // B)
        ans = max(tmp, ans)

    print(ans)


resolve()

Submission status: Wrong Answer

Solution code:
from math import floor
from collections import deque

def main():
    A,B,N=map(int,input().split())
    d=deque()
    for x in range(N+1):
        tmp=floor(A*x/B)-A*floor(x/B)
        #print(floor(A*x/B)-A*floor(x/B))
        if tmp<floor(A*(x-1)/B)-A*floor((x-1)/B) and x>=1:
            break
        else:
            d.append(tmp)
    
    num=len(d)
    ans=d[N%num]
    print(ans)
        
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

if b >= n:
    t = int(a * n / b) - a * int(n/b)
else:
    t = int(a * n / b) - a * int(n/b)
    for i in range(10000000):
        t_ = int(a * (n+i) / b) - a * int((n+i)/b)
        if t_ > t:
            t = t_
print(t)

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

import math

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

if b//n == 0:
    print(tmp1)
else:
    q, _ = divmod(n, b)
    x = q*b-1
    tmp2 = math.floor(a*x/b) - a*math.floor(x/b)
    print(max(tmp1, tmp2))

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
maxi=0
ele=0
for i in range(n,n-1000000,-1):
    val=int((a*i)/b)-(a*int(i/b))
    if(val>maxi):
        maxi=val
        ele=i
print(maxi)

Submission status: Wrong Answer

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

cnt=0

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

Submission status: Wrong Answer

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

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

ans = 0
for i in range(0,min(N+1,B+1),1000):
    t = calc(i)
    if ans > t:
        break
for j in range(max(0,i-1000),min(N+1,1000)):
    ans = max(ans,calc(j))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

A,B,N = map(int,input().split())
if A>B:
  print( math.floor(A*N/B) - A * math.floor(N/B))
  exit()
ans =0
for x in range(1,B):
  num = math.floor(A*x/B) - A * math.floor(x/B)
  if num > ans:
    ans = num
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(N-1000000, N):
            tmp = (A*x//B)-A*(x//B)
            ans = max(ans, tmp)
print(ans)

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):
	return math.floor(a*x/b)-a*math.floor(x/b)


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

a,b,n=input2()
b_ans=fl(a,b,n)

for i in range(1,n+1,b):
	ans=fl(a,b,i)
	if ans> b_ans:
		b_ans=ans
	if i>b:
		break
print(b_ans)

Submission status: Wrong Answer

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

c = 0
ans = 0

if N < 1000:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
else:
  for i in range(N-999999,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
print(int(ans))

Submission status: Wrong Answer

Solution code:
line = input().split(" ")
A = int(line[0])
B = int(line[1])
N = int(line[2])
max = 0
for x in reversed(range(N+1)):
    S = int(A * x / B) - A * int(x / B)
    print(x)
    if max<S:
        max = S
    if int(x/B) != 0:
        break
print(max)

Submission status: Wrong Answer

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

n = 0

for i in range(N):
    
    _n = int(A*N/B) - A*int(N/B)
    if n < _n:
        n = _n

print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
f = lambda x : A*x//B - A*(x//B)
l, r = 0, N
while l+1 < r:
    t, u = 2*l/3+r/3, l/3+2*r/3
    if f(t) < f(u):
        l = t
    elif f(t) > f(u):
        r = u
    else:
        l = t
print(f(int(r)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def fl_m(a,b,n):
  if n>=(a-1)*b/a:
    z=a-1
  else:
    k=int(n*a/b)
    z=k
  return(z)
    
print(fl_m(A,B,N))

Submission status: Wrong Answer

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

from math import floor

def f_ans(X):
  return floor(a*X/b) - a * floor(X/b)

if b < n:
  print(f_ans(b-1))
else:
  print(f_ans(n))

# for i in range(1,n+1):
#   print(str(i) + ':' + str(f_ans(i)))

Submission status: Wrong Answer

Solution code:
import math

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

max=0
x_max=-1

for x in range(A-k,A+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(B-k,B+k):
	if x>0 and x<=N:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(N-k,N+1):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x

for x in range(0,k):
	if x>0:
		tmp = math.floor(A*x/B)-A*math.floor(x/B)
		if max<=tmp:
			max=tmp
			x_max=x			
print(max)

Submission status: Wrong Answer

Solution code:
# Code for D - Floor Function
# Use input() to fetch data from STDIN
from math import floor

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

max_result = 0
for x in range(min(a * 2, n)):
    x = x + 1
    r = floor(a * x / b) - a * floor(x / b)
    if r > max_result:
        max_result = r

print(max_result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

x=min(B-1,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())

if b >= n:
    t = int(a * n / b) - a * int(n/b)
else:
    t = int(a * n / b) - a * int(n/b)
    for i in range(10000):
        t_ = int(a * (n+i) / b) - a * int((n+i)/b)
        if t_ > t:
            t = t_
print(t)

Submission status: Wrong Answer

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

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

baisu = lcm(a, b)
num = int(baisu / a)
m = 0
for i in range(1, num):
    if n < i:
        break
    result = int(a * i / b) - a * int(i/b)
    if m < result:
        m = result

print(m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = -1
for x in range(n-int(n**(1/2))-1,n+1):
    abc = ((a*x)//b)-(a*(x//b))
    if(ans < abc):
        ans = abc

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
a, b, n = [int(x) for x in input().split()]
def e(x):
	return floor(a * x / b) - a * floor(x / b)
candidates = [a, a - 1, b-1, b, n-1, n]
print(max(*[e(x) for x in candidates if x >= 1 and x <= n]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
ans = 0
if N <= B:
    for i in range(N):
        i = N-1 - i
        r = (A*i)//B - A*(i//B)
        if r > ans :
            ans = r
        else:
            break
else:
    for i in range(B):
        i = B-1 - i
        r = (A*i)//B - A*(i//B)
        if r > ans :
            ans = r
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if a==1 or b== 1 or n==1:
  print(0)
  exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import floor

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

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

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

for i in reversed(range(1, N + 1)):
    if i < B:
        print(((A * i) // B) - (A * (i // B)))
        exit()

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 > 1:
    S /=10
    Npower += 1
if Npower >= 6:
    diff = N-1000
    for i in range(0,1000):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
    for i in range(diff,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
else:
    for i in range(0,N+1):
        maxi = max(floor(A*i/B)-A*floor(i/B),maxi,0)
print(maxi)

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)-100000)*A)/B
    now_2 = max(1, int(N)-100000)/B

    for i in range(max(1, int(N)-100000), int(N) + 1):
        if i %100 == 0:
            now_1 = (i*A) / B
            now_2 = i / B
        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=input().split(" ")
A=int(A)
B=int(B)
N=int(N)
s=[]
for x in range(0,N):
    y=int((A*x)/B)
    z=int(x/B)
    p=y-A*z
    s.append(p)
print(max(s))

Submission status: Wrong Answer

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


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

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

print(f(left))

Submission status: Wrong Answer

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

cnt=0

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

A,B,N = LI()

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

d,m = divmod(N+1,B)
x1 = max(d*B-1,0)
x2 = N

print(max(calc(x1),calc(x2)))

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 = 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:
#!python3

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


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


def main():
    if N < B:
        ans = f(N)
        print(ans)
        return
    
    l = []
    l.append(f(B - 1))
    l.append(f(N) if N % B != 0 else f(N - 1))
    l.append(f(N // B * B - 1))
    l.append(N)

    ans = max(l)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

s=N//B

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

#print(x)

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


#print(a,b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
maxr = 0
minr = 0
ans = 0
if b < n:
    maxr = b + 1
    minr = abs(b - 1000000) if abs(b - 1000000) < b else 0
else:
    maxr = n + 1
    minr = abs(n - 1000000) if abs(n - 1000000) < n else 0
for i in range(minr, maxr):
    c = math.floor(a * i / b) - math.floor(i / b) * a
    ans = max(ans, c)
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
f = lambda x : A*x//B - A*(x//B)
l, r = 0, N
while l+1 < r:
    t, u = 2*l/3+r/3, l/3+2*r/3
    if f(t) < f(u):
        l = t
    elif f(t) > f(u):
        r = u
    else:
        l = t
print(f)

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
ans = 0
for i in range(A):
    x = N - i
    if x < 0:
        break
    tmp = int(A * (x % B / B) - (A * x % B) / B)
    if tmp >= ans:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

cnt=0

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
c = 0
for i in range(1,n+1):
    tmp = (math.floor(a*i/b)-a*math.floor(i/b))
    if c < (math.floor(a*i/b)-a*math.floor(i/b)):
        c = (math.floor(a*i/b)-a*math.floor(i/b))
    elif c > 0 and c >= (math.floor(a*i/b)-a*math.floor(i/b)):
        print(c)
        exit()
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

x = 0
answers = []

ryuudo = N / 10

while x <= N:
    answers.append(math.floor(A * x / B) - A * math.floor(x / B))
    x += ryuudo

x = (answers.index(max(answers)) - 2) * ryuudo
stop = (answers.index(max(answers)) + 2) * ryuudo


if x < 0:
    x = 0

answers = []

while x <= stop and x <= N:
    answers.append(math.floor(A * x / B) - A * math.floor(x / B))
    x += 1

print(max(answers))

Submission status: Wrong Answer

Solution code:
def gcd(x, y) -> int:
    if y == 0:
        return x
    elif y == 1:
        return 1
    elif x < y:
        return gcd(y, x)
    else:
        return gcd(y, x % y)

a, b, n = map(int, input().split())
ans = 0
if n >= b:
    g = gcd(a, b)
    ans = g * (a // g - 1)
else:
    ans = int(a * n / b) - a * int(n / b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
x = 0
ans1 = 0
while x <= N and x <= 10**6:
    ans = int((A*x)/B) - A * int(x / B)
    ans1 = max(ans1, ans)
    x += 1

print(ans1)

Submission status: Wrong Answer

Solution code:
import math

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

p = N*(N%B)-1
q = ans=math.floor(A*p/B)-A*math.floor(p/B)


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

print(max(q,ans))

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#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 = []

for i in range(N):
    list.append(math.floor(A*i/B)-A*math.floor(i/B))


print(max(list))

Submission status: Wrong Answer

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

c = N // B

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

if c != 0:
    ans2 = int(A*(B-1)/B) - A * int((B-1)/B)
ans = max(ans1, ans2)

print(ans)

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
    #print("x=",x)
    #print(MAX, MAXX, "1")
    MAXX = MAX
    f = floor(A*x, B)
    b = A * floor(x, B)
    MAX = f - b
    #print(MAX, MAXX, "2")


print(MAXX)

Submission status: Wrong Answer

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

c = 0
ans = 0

if N < 1000:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
else:
  for i in range(N-999,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c
    
print(int(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'''

print(max(int(a*(n-1)/b) - a*int((n-1)/b), int(a*n/b) - a*int(n/b)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:


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

max_ = -A
for x in range(B+1):
    num = int((A*x)/B) - A * int(x/B)
    if num > max_:
        max_ = num


print(max_)

Submission status: Wrong Answer

Solution code:
a=list(map(int, input().split()))
A=a[0]
B=a[1]
N=a[2]
if B<N:
    i=int(A*(B-1)/B)-A*int((B-1)/B)
else:
    i=int(A*N/B)-A*int(N/B)
print(i)

Submission status: Wrong Answer

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

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

print(max(int(ans), 0))

Submission status: Wrong Answer

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


floor_num=[]
for x in range(N+1):
    floor_num.append(int(A*x/B)-A*int(x/B))
    print((int(A*x/B)-A*int(x/B)))

print(max(floor_num))