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: Runtime Error

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

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


print(ans)

Submission status: Runtime Error

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

left = 1
right = n

while right - left > 1:
    x = (left + right) // 2
    k = a*x
    l = x//b
    p = a*(x+1)
    q = (x+1)//b
    if (k//b-a*l) < (p//b-a*q):
        left = x
    else:
        right = x

s = (p//b-a*q)

print (s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for x in range(N + 1):
  result = math.floor((A * x)/B) - A * math.floor(x/B)
  if (maxResult < result):
    maxResult = result
print(maxResult)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
if b<n:
    n=b
for i in range(1,n+1):
    if i<b:
        s=math.floor(a*i/b)
    if s>max:
        max=s
print(int(max))

Submission status: Runtime Error

Solution code:
#include<stdio.h>
#include<math.h>
void main(){
	int a,b,n,temp,i,arr[100];
	scanf("%d%d%d",&a,&b,&n);
	for(i=0;i<=n;i++)
	{
		arr[i]=floor((a*i)/b)-(a*(floor(i/b)));
		
	}
	for(i=0;i<=n;i++)
	{
		if(arr[0]<arr[i])
		{
			temp=arr[0];
			arr[0]=arr[i];
			arr[i]=arr[0];
		}
	}
	printf("%d",arr[0]);

}

Submission status: Runtime Error

Solution code:
import math

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

if n>=b:
	n1 = n//b*b-1
	n2 = n//b*b-2
	ans = max(math.floor(a*n/b)-a*math.floor(n/b), max(math.floor(a*n1/b)-a*math.floor(n1/b)), math.floor(a*n2/b)-a*math.floor(n2/b))
else:
	ans = math.floor(a*n/b)-a*math.floor(n/b)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import sys

a, b, n = map(int, input().split())
array = np.arange(1, n+1, math.ceil(1/10**5))
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
a, b, n = map(int, input().split())
x = np.arange(1 + (n // b), n + 1)
y = np.floor(a * x / b) - a * np.floor(x / b)
print(int(y.max()))

Submission status: Runtime Error

Solution code:
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)

a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    x = b*k-1
    print(f(a,x,b) - a*f(x,b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

if b <= a:
    if n >= b:
        x = b - 1
        print(math.floor(a * x / b))
    elif n < b:
        x = n
        print(math.floor(a * x / b))
elif b > a:
    if n >= b:
        x = math.ceil(n / b) - 1
        print(math.floor(a * x / b)) - a * math.floor(x / b)
    elif n < b:
        x = n
        print(math.floor(a * x / b))

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
if(n<b):
  print(floor((a*n)/b))
elif(n==b or n%b==0):
  print(floor((a*(n-1))/b))
else:
  for i in range(1,(n%b)+1):
    print(floor((a*(n-2-i))/b)-(a*floor((n-2-i)/b)))

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
A = A//G
if A%B:
    invA = mod_inv(A,B)
else:invA = 0

if B == 1:
    print(0)
else:
    InvList = []
    if A == 1:
        InvList.append((0,N,Old_A//B))
    for i in range(min(A,B)+1):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:
            amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        x -= 1
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

Solution code:
c=list(map(int,input().split()))
bunsi=c[0]
bunbo=c[1]
n=c[2]
k=n//bunbo
d=[n]
if k!=0:
    for i in range(0,k):
        d.append(bunbo*(i+1)-1)
#dの中には候補となるxが入った
def floor(x):
    return ((bunsi*x)//bunbo)-(bunsi*(x//bunbo))
print(max(floor(d[0]),floor(d[-1]),floor(d[-2])))

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	ax = A * x
	if x >= B:
		t = int(ax / B) - A * int(x / B)
	elif ax >= B and x < B:
		t = int(ax / B)
	elif ax < B:
		continue

	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    if N > B:
        start = max(B-100000,1)
        init_1 = (max(1, int(B-100000)) * A) / B
        init_2 = max(1, int(B-100000)) / B
        for i in range(max(int(B)-100000,1), max(N,int(B)+1)):
            ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

    return math.floor(a*x/b)-(a*math.floor(x/b))
if n%2==0:
    nmid=n/2
if n%2==1:
    nmid=n+1/2
for i in range(nmid):
    if i>teisuu:
        break
    temp=nmid-i
    maxtemp=max(maxtemp,funcsum(temp))

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

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


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

Submission status: Runtime Error

Solution code:
A, B, N = map(int, input().split())
max = 0
wait = int(B/A)
for x in range(1, N+1, wait):
    fun = int(A*x/B) - A*int(x/B)
    if x == 1:
        x0 = fun
    elif x > wait:
        if x0 == fun:
            break
    if max < fun:
        max = fun
print(max)

Submission status: Runtime Error

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

#for i in range(c+1):
d=math.floor(a*i/b)-a*math.floor(i/b)
print(d)

Submission status: Runtime Error

Solution code:
#include<stdio.h>
#include<math.h>
void main(){
	int a,b,n,temp,i,arr[100];
	scanf("%d %d %d",&a,&b,&n);
	for(i=0;i<=n;i++)
	{
		arr[i]=floor((a*i)/b)-(a*(floor(i/b)));
		
	}
	for(i=0;i<=n;i++)
	{
		if(arr[0]<arr[i])
		{
			temp=arr[0];
			arr[0]=arr[i];
			arr[i]=arr[0];
		}
	}
	printf("%d",arr[0]);

}

Submission status: Runtime Error

Solution code:
import math
A,B,N = map(int, input().split())  
ANS=[0]*(N)
k=1
for i in range(N):
  ANS[i]=math.floor(A*k/B)-(A*math.floor(k/B))
  k+=1
ANS.sort()
print(ANS[-1])

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	ax = A * x
	if x >= B:
		t = int(ax / B) - A * int(x / B)
	elif ax >= B and x < B
		t = int(ax / B)
	elif ax < B:
		continue

	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

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

for i in range(n,0,-1):
    if i/b < 1:
        res = floor(a*i/b) - a * floor(i/b)
        break

print(res)

Submission status: Runtime Error

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

max_s = []
j = 0
if n > 10**6:
    print(int((a*n)/b) - a*int(n/b))
else:
    for i in range(n,0,-1):
        j += 1
        if j == int(10**6):
            break
        else:
            num = int((a*i)/b) - a*int(i/b)
            max_s.append(num)
print(max(max_s))

Submission status: Runtime Error

Solution code:
import math

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

    return math.floor(a*x/b)-(a*math.floor(x/b))
if n%2==0:
    nmid=n/2
if n%2==1:
    nmid=n+1/2
for i in range(n/2):
    if i>teisuu:
        break
    temp=nmid-i
    maxtemp=max(maxtemp,funcsum(temp))

for i in range(n/2):
    if i>teisuu:
        break
    temp=nmid+i
    maxtemp=max(maxtemp,funcsum(temp))
print(maxtemp)

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


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

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
A = A//G
if A%B:
    invA = mod_inv(A,B)
else:invA = 0

if B == 1:
    print(0)
else:
    InvList = []
    if A == 1:
        InvList.append((0,N,Old_A//B))
    for i in range(min(Old_A,B)+1):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        x -= 1
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        if x < 0:continue
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

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

k = [0]*(math.floor(N/B)+1)
 
for i in range (1, math.floor(N/B)+2):
	k[i-1] = i*B-1
 
k[-1]=N
 
boom=0
 
for i in range (0, len(k)):
	p = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
	if p > boom:
		boom = p
 
print(boom)

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
max=-2
lim=min(n,b)
for i in range(1,lim+1):
    if i<b:
        s=math.floor(a*i/b)
    else:
        s=math.floor(a*i/b)-a*floor(i/b)
    if s>max:
        max=s
print(int(max))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import itertools
n,m,q=map(int,input().split())
abcd=[None]*q
for i in range(q):
    abcd[i]=list(map(int,input().split()))
num=0
for l in list(map(list, itertools.combinations(list(range(1,m+1))*m, n))):
    num_ = 0
    for x in abcd:
        if l[x[1]-1]-l[x[0]-1] == x[2]:
            num_ += x[3]
    num = max(num ,num_)
print(num)

Submission status: Runtime Error

Solution code:
from decimal import Decimal, getcontext

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

lo = 1
hi = N

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

ans = 0
if B-1<=N:
    ans = f(B-1)

while hi > lo :
    if f(lo) <= f(hi):
        mid = (lo + hi) // 2
        if f(mid)<=f(mid+1):
            lo = mid+1
        else:
            lo = mid
    else:
        mid = -(-(lo + hi) // 2)
        hi = mid

ans = max(ans,f(lo),f(N-1),f(B*N//B-1))

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

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

def main():
    A,B,N = map(int,input().split())
    if N <= B-1:
        ans = cal(A,B,N)
    else:
        a,b = A//gcd(A,B),B//gcd(A,B)
        if N % B == 0:
            ans = cal(A,B,b*d-1)
        else:
            ans = cal(A,B,N)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

x = n//(b-1)
y = 0
for i in range(x+1):
    if (i*b-1) <= n:
        y = max(int(a*(i*b-1)/b) - a*int((i*b-1)/b), y)
y = max(int(a*n/b) - a*int(n/b), y)
print(y)

Submission status: Runtime Error

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

if (n >=b):
  x=math.floor(n/b)*b-1
  print (math.floor(a*x/b)-a*math.floor(x/b))
#  print (int(a*(int(n/b)-1./b))-a*int(int(n/b)-1./b))
else:
#  xmax=0
#  for x in range(1,n+1):
#    atai=int(a*x/b)-a*int(x/b)
#    if (atai >= xmax): xmax=atai
#  print (xmax)
  print (math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Runtime Error

Solution code:
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,min(a+1,n+1)):
        left = ia*x/b//1
        right = a * x/b//1
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

k = [0]*(math.floor(N/B)+1)
 
for i in range (1, math.floor(N/B)+2):
	k[i-1] = i*B-1
 
k[-1]=N
print(k)
 
boom=0
 
for i in range (0, len(k)):
	p = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
	if p > boom:
		boom = p
 
print(boom)

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
ans = []
for x in range(1, N//(10**6)+1 ):
    cal = math.floor((A*x)/B) - (int(A) * math.floor(x/B))
    ans.append(cal)
print(max(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
c=max(0,a//b)
d=min(b,n)
def floor(x):
    return int((a*x)/b)-a*(int(x/b))
if n<=b:
    print(floor(n))
else:
    if b<a:
        print(floor(b-1))
    elif b=a:
        print(floor(b))
    else:
        e=max(b-1,a//b)
        print(floor(e))

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
A = A//G
if A%B:
    invA = mod_inv(A,B)
else:invA = 0

if 1:   
    InvList = []
    if A == 1:
        InvList.append((0,N,Old_A//B))
    for i in range(min(Old_A,B)+1):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        x -= 1
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        if x < 0:continue
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Submission status: Runtime Error

Solution code:
import sys
import math
import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

# ===CODE===

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

left = 1
right = n

ans = 0
num = 0
while abs(left - right) > 10**(-8):
    tmp_left = left + (right - left) / 3
    tmp_right = left + 2 * (right - left) / 3

    c_left = math.floor(a * left / b) - a * math.floor(left / b)
    c_right = math.floor(a * right / b) - a * math.floor(right / b)

    f_left = math.floor(a * tmp_left / b) - a * math.floor(tmp_left / b)
    f_right = math.floor(a * tmp_right / b) - a * math.floor(tmp_right / b)

    if c_left < f_left < f_right:
        left = tmp_left
        if ans < f_left:
            ans = f_left
            num = tmp_left
    else:
        right = tmp_right
        if ans < f_right:
            ans = f_right
            num = tmp_right

    ans1 = math.floor(a * int(num) / b) - a * math.floor(int(num) / b)
    ans2 = math.floor(a * int(num+1) / b) - a * math.floor(int(num+1) / b)

print(int(max(ans1,ans2)))

Submission status: Runtime Error

Solution code:
import numpy as np
a, b, n = map(int, input().split())
x = np.arange(1, n + 1)
y = np.floor(a * x / b) - a * np.floor(x / b)
print(int(y.max()))

Submission status: Runtime Error

Solution code:
import math
import numpy as np
A,B,N=map(int,input().split())
range_list=list(range(0,N+1))
data2 = list(map(lambda x: math.floor(A*x/B)-(A*math.floor(x/B)), range_list))
print(max(data2))

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
# xはN以下
# int(A*x/B) - A*int(x/B)の最大値を求めたい

# g(x)はBごとに数値が変わるので、Bで区切って計算すれば計算量を減らせる。
# その区間で、Bで割った余りがB-1、つまり最後の点が一番高い数値を出す。
# よって、計算量はN%B

# まずは区間を出す
compute_range = list(range(0, math.ceil(N / B)))
# print(compute_range)
# この区間の中で、二分探索する
# 01だと1の方が数値が大きいことがわかったら、次はその中で末尾を取る。
# ただし、範囲外にはならないように


def h(x):
    return (int((A * x) / B) - A * int(x / B))


if N > B:
    max_num = h((compute_range[-1] + 1) * B - 1)
else:
    max_num = h(N)

# max_num = 0
# for i in range(B):
#     index = compute_range[-1] * B + i
#     if index > N:
#         continue
#     max_num = max(max_num, h(index))

print(max_num)

Submission status: Runtime Error

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    start = max(B-1000,1)
    init_1 = (max(1, int(B-100000)) * A) / B
    init_2 = max(1, int(B-100000)) / B
    for i in range(max(int(B-100000),1), max(N,int(B)+1)):
        ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import numpy as np

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

x = np.arange(0, N+1)
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

Submission status: Runtime Error

Solution code:
import math

A,B,N=map(int,input().split())
ans=[0]*(N+1)
for x in range(0,N+1):
    a=math.floor(A*x/B)
    b=A*math.floor((x/B))
    ans[x]+=a-b
print(ans)

Submission status: Runtime Error

Solution code:
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
if A%B:
    invA = mod_inv(A,B)
else:invA = 0

if 1:   
    InvList = []
    if A == 1:
        InvList.append((0,N,Old_A//B))
    for i in range(min(A,B)+1):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        x -= 1
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        if x < 0:continue
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

Solution code:
import math

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

ans = 0

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

if a == b :
    ans = math.floor(a * (a - 1) / b) - a * math.floor((a - 1) / b)

if a < b :
    # print('a < b')
    # for x in range(n):
    #     temp = math.floor(a * x / b) - a * math.floor(x / b)
    #     print(temp)

    for x in range(b - 1, n + 1, b):
        # print(x)
        temp = math.floor(a * x / b) - a * math.floor(x / b)
        # print(temp)

    if ans <= temp :
        ans = temp

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
a, b, n = map(int, input().split())
x = np.arange(1, n + 1)
y = np.floor(a * n / b) - a * np.floor(n / b)
print(int(y.max()))

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

A, B, N = map(int, input().split()) # 2以上の整数入

ans = 0
for x in np.array(range(N)) + 1:
	t = 0
	ax = A * x
	if B > x and B > ax:
		t = 0
	elif B <= x and B > ax:
		continue
	elif B <= ax and B > x:
		t = int(ax / B) 
	else:
		t = int(ax / B) - A * int(x / B)
	if t > ans:
		ans = t

print(ans)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:

import math
import copy
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

A,B,N = [int(hoge) for hoge in input().split()]
G = math.gcd(A,B)
Old_A = copy.deepcopy(A)
if A%B:
    invA = mod_inv(A,B)
else:invA = 0

if 1:   
    InvList = []
    if A == 1:
        InvList.append(0,N,Old_A//B)
    for i in range(min(A,B)+1):
        #Ax=i(modB)なので、x = i*(inv_A) mod B
        if i:
            amari = (i * invA)%B #候補のx mod B
        else:amari = 0# Ax mod B=0 のとき、x mod B = 0
        x = N - N%B + amari
        if x > N :x-=B
        x -= 1
        axx = (amari,x,(Old_A*x)//B - Old_A * (x//B))
        if x < 0:continue
        InvList.append(axx)
    InvList.append((0,N,(Old_A*N)//B - Old_A * (N//B)))
    InvList.sort(key = lambda x:x[2],reverse=True)
    print(InvList[0][2])

Submission status: Runtime Error

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

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

if A > B:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))

Submission status: Runtime Error

Solution code:

A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)

Submission status: Runtime Error

Solution code:
import math


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

    ans = 0
    div_ab = A/B
    div_1b = 1/B
    init_1 = (max(1, int(N)-100000)*A)/B
    init_2 = max(1, int(N)-100000)/B
    start = max(1, int(N)-100000)

    for i in range(max(1, int(N)-100000), int(N) + 1):
        ans = max(math.floor(init_1+div_ab*(i-start)) - A*math.floor(init_2+div_1b*(i-start)),ans)
    start = max(B-1000,1)
    init_1 = (max(1, int(B-100000)) * A) / B
    init_2 = max(1, int(B-100000)) / B
    for i in range(max(B-100000,1), int(B)+1):
        ans = max(math.floor(init_1 + div_ab * (i - start)) - A * math.floor(init_2 + div_1b * (i - start)), ans)

    print(int(ans))


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
 
if N <B:
	print(math.floor(A*N/B))
	exit()
 
k = [0]*(math.floor(N/B)+1)
 
for i in range (1, math.floor(N/B)+2):
	k[i-1] = i*B-1
 
for i in range (0, len(k)):
	if k[i] > N:
		k[i]=0
 
boom=0
 
for i in range (0, len(k)):
	p = math.floor(A*k[i]/B)-A*math.floor(k[i]/B)
	if p> boom:
		boom = p
 
print(boom)

Submission status: Runtime Error

Solution code:

def resolve():
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

if __name__ == '__main__':
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

max_v = 0
if A > B:
    for i in range(0, N + 1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        # print(current_max_v, end="")
        if i != 1 and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
if B >= A:
    for i in range(N + 1, 0, -1):
        current_max_v = math.floor(A * i // B) - A * math.floor(i / B)
        max_v = max(max_v, current_max_v)
        # print(current_max_v, end="")
        if i != N + 1 and current_max_v < current_max_vb:
            break
        current_max_vb = current_max_v
print(max_v)

Submission status: Runtime Error

Solution code:
A,B,N = list(map(int,input().split()))
if N <= 10000:
    C = [A*i//B-(A*(i//B)) for i in range(1,N+1)]
    print(max(C))
    exit()
C = [A*i//B-(A*(i//B)) for i in range(100)]
D = [A*i//B-(A*(i//B)) for i in range(N,-1,N-100)]
E = max(max(C),max(D))

Submission status: Runtime Error

Solution code:
k = list(map(int, input().split()))

import math
def calc(l):
  t = l / k[1]
  re1 = math.floor(k[0] * t) - k[0] * math.floor(t)
  re2 = math.floor(k[0] * (t + 1)) - k[0] * math.floor(t +1)
  if re1 > re2:
    l = l // 2
    return (l, re1)
  else:
    l = l + (l //2)
    return (l, re2)

l = k[2] // 2
now = calc(l)
re = 0
while now(1) > re:
  now = calc(l)
  
print(now)

Submission status: Runtime Error

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

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

F12 = []

for i in range(1, B):
    x = i
    f1 = int(A*x/B) 
    f2 = A * int(x/B)
    F12.append(f1-f2)

if N < B:
    print(F12[N-1])
else:
    print(F12[-1])

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
res = 0
ans = 0
for i in range(1,N+1):
    res_bar = math.floor((A*i)/B)-A*math.floor(i/B)
    if res_bar >= res:
        res = res_bar
        ans = i
    else:
        break

        
        
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

def check():
    x = np.arange(1, N+1)
    tmp = np.floor(A * (x/B) ) - (A * np.floor(x / B))
    print(int(max(tmp)))
        
check()

Submission status: Runtime Error

Solution code:
a,b,n = map(int,input().split())
import math
def func(x):
    y = math.floor(a*x/b)-a*math.floor(x/b)
    return y

if b > n:
    for i in range(1,n+1):
        ans.append(func(i))
        print(max(ans))
else:
    print(func(b*((n//b)-1)+b-1))