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())
if b>n:
	l=a*n//b
elif b<n:
  l=-10000
  for i in (b,n):
    d=a*i//b-a*(i//b)
    if d>l:
      l=d
print(l)

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
if n < b:
    x = n
else:
    x = b-1
while x >= 0:
    val = (a*x)//b-a*(x//b)
    if val < com:
        pass
    else:
        com = val
    x -= 1
print(com)

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
elif B//A > 1:
  	D = B//A-0.1
else:
    D = B//A
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:
import math
a, b, n = map(int, input().split())

y = b-1
if x < n:
  x = y
else:
  x = n

print(math.floor(a*x/b))

Submission status: Runtime Error

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

A, B, N = map(int, input().split())
x = min(B-1, N)
print(f(x))

Submission status: Runtime Error

Solution code:
import sys
 
def solve(A: int, B: int, N: int):
    x = min(B - 1, N)
    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()
#!/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: Runtime Error

Solution code:
import math
x = int(input())
finished = False
# b >= 0 check
a = max(0,int(math.pow(x,0.2)) - 1)
while a**5 - (a-1)**5 <= x:
    tmp = a**5 - x
    if tmp < 0:
        a += 1
        continue
    b = int(math.pow(tmp,0.2))
    if a**5 - b**5 == x:
        finished = True
        print(a,b)
        break
    a += 1
if not finished:
    a = 1
    while a**5 < x:
        tmp = x - a**5
        b = int(math.pow(tmp,0.2))
        if a**5 + b**5 == x:
            finished = True
            print(a,-b)
            break
        a += 1

Submission status: Runtime Error

Solution code:
import math
import sys

a, b , n = map(int, input().split())
ans = []
i=1
while i <= n:
    ans.append(math.floor(a*i / b) - a*math.floor(i/b))
    if (i >= 2) and (ans[i] < ans[i-1]):
        break
    i += 1
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
import sys

a, b , n = map(int, input().split())
ans = []
i=1
while i <= n:
    ans.append(math.floor(a*i / b) - a*math.floor(i/b))
    if ans[i] < ans[i-1]:
        print(i -1)
        sys.exit()
    i += 1
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
import sys

a, b , n = map(int, input().split())
ans = []
for i in range(1, n):
    ans.append(math.floor(a*i / b) - a*math.floor(i/b))
    if ans[i] < ans[i-1]:
        print(i -1)
        sys.exit()
    
print(max(ans))

Submission status: Runtime Error

Solution code:
import math
import sys

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

Submission status: Runtime Error

Solution code:
import math
import sys

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

Submission status: Runtime Error

Solution code:
A,B,X = map(int,input().split())
print(min(B-1,N))

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
def kansu(x):
  S = floor(A*x/B)
  return S
print(min(kansu(N), kansu(B)))

Submission status: Runtime Error

Solution code:
import floor from math
A, B, N = map(int, input().split())
def kansu(x):
  S = floor(A*x/B)
  return S
print(min(kansu(N), kansu(B)))

Submission status: Runtime Error

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

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

ans_list = []

for i in range(int(b / 2), n + 1):
  #print(int((a * i) / b), a * int(i / b), int((a * i) / b) - a * int(i / b))
  ans = int((a * i) / b) - a * int(i / b)
  ans_list.append(ans)
print(max(ans_list))

Submission status: Runtime Error

Solution code:
import numpy as np

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

s = B-1 if N > B-1 else N

x = np.arange(0, s+1)
X = A * (x % B) - (A * (x % B)) % B

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

Submission status: Runtime Error

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

def f(a, b, n):
    fl1 = (a * (n + 1)) // b
    fl2 = (n + 1) // b
    fl = fl1 - a * fl2
    return fl

print(f(a, b, b-1) if n >= b-1 else f(a, b, n))

Submission status: Runtime Error

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

def floor(x):
    return int(A * x / B)

for i in range(0,min(N,B-1):
    Get.append(floor(i))
print(max(Get))

Submission status: Runtime Error

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

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

print(max(ans))

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3

import math
#標準出力からの読み込み
input_1 = input()
a = int(input_1.split(" ")[0])
b = int(input_1.split(" ")[1])
n = int(input_1.split(" ")[2])


#判定ロジック
score = math.floor(a/b*math.min(b-1, n))
print(score)

Submission status: Runtime Error

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

def floor(x):
    return int(A * x / B) - A * int(x / B)
for i in range(1,N):
    Get.append(floor(i))
print(max(Get))

Submission status: Runtime Error

Solution code:
import numpy as np
A,B,N = map(int,input().split())
def f(x):
    return floor(A * x / B) - A * floor(x / B)
def floor(x):
    return x.astype(np.int64)
xArray = np.asarray(range(1,N+1))
score = np.zeros(len(xArray),np.int64)
score += f(xArray)
print(score.max())

Submission status: Runtime Error

Solution code:
import numpy as np
A,B,N = map(int,input().split())
narray = np.asarray(range(1,N+1))
store = np.zeros(len(narray),np.int64)
AxPerB = (A * narray) / B
xPerB = (narray / B)
store += AxPerB.astype(np.int64) - A * xPerB.astype(np.int64)
print(store.max())

Submission status: Runtime Error

Solution code:
import numpy as np
A,B,N = map(int,input().split())
narray = np.asarray(range(1,N+1))
store = np.zeros(len(narray),np.int32)
AxPerB = (A * narray) / B
xPerB = (narray / B)
store += AxPerB.astype(np.int32) - A * xPerB.astype(np.int32)
print(store.max())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

    A, B, N = map(int, input().split())
    x = min(B-1, N)
    print(f(x))

if __name__ == "__main__":
    resolve():

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
s=math.floor((A*(B-1))/B))
t=math.floor((A*N)/B))
print(max(s,t))

Submission status: Runtime Error

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

max - int(a*min(B-1,N)/B)
print(max)
~

Submission status: Runtime Error

Solution code:
import sys
a,b,n = map(int,input().split())
d = 0
i = 0
for i in range(1,n+1):
    c = int(a*i/b)-a*int(i/b)
    if c >= d:
        d = c
    else:
        j += 1
        if j > 1:
            print(int(a*(j-2)/b)-a*int((j-2)/b))
            sys.exit()
print(d)

Submission status: Runtime Error

Solution code:
a, b, n = [int(x) for x in input().split()]
x = min(b - 1, n)
answer = floor(a * x / b) - a * floor(x / b)
print(answer)

Submission status: Runtime Error

Solution code:
import math
max_num = 0
A, B, N = map(int, input().split())
for x in range(1, N+1):
    num1 = math.floor(Ax/B)
    num2 = math.floor(x/B)
    num3 = num1-num2
    if max < num3:
        max = num3
                       
print(max_num)

Submission status: Runtime Error

Solution code:
comb = []
def f(n,cnt,ls):
    if cnt == n:
        comb.append(ls)
        return
    for i in range(ls[cnt-1],m+1):
        tmp = ls.copy()
        tmp[cnt] = i
        f(n,cnt+1,tmp)
    return
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,m,q = ma()
abcd = []
for i in range(q):
    abcd.append(list(ma()))
ls = [1]*(n+1)
f(n,0,ls)
ans = 0
for A in  comb:
    tmp = 0
    for a,b,c,d in abcd:
        if A[b-1] - A[a-1] ==c:
            tmp +=d
    ans = max(ans,tmp)
print(ans)

Submission status: Runtime Error

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

for i in range(0,B+1):
    s = math.floor(a * i / b)
    t = math.floor (i/b)
    ans = max(ans,s - a*t) 

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N < B:
  floor = int(A*N/B) - A*int(N/B)
else:
  floor = max([(int(A*(x-1)/B) - A*int((x-1)/B)) for x in range(B,N,B)])
print(floor)

Submission status: Runtime Error

Solution code:
import math

n = list(map(int,input().split()))
x = min(b-1 , n[2])
if n[2] >= n[2]:
    print(math.floor(n[0] * x / n[1]))

Submission status: Runtime Error

Solution code:
import math

n = list(map(int,input().split()))
#hikaku = 0

#for x in range(1,n[2]+1):
#    m = math.floor(n[0] * x // n[1]) - n[0] * math.floor(x // n[1])
#    if hikaku < m:
#        hikaku = m

x = min(b-1 , n[2])
if n[2] >= n[2]:
    print(math.floor(n[0] * x // n[1]))

Submission status: Runtime Error

Solution code:
A,B,N = map(int, input().split(' '))
p = min(N,B)
if p%B == 0:
    print(int(A(p-1)/B))
else :
    print(int(A(p)/B))

Submission status: Runtime Error

Solution code:
A,B,N = map(int, input().split(' '))
c = min(N,B)
if c % B == 0:
    print(int(A(c-1)/B))
else :
    print(int(A(c)/B))

Submission status: Runtime Error

Solution code:
A,B,N = map(int, input().split(' '))
c = min(N,B)
if p % B == 0:
    print(int(A(c-1)/B))
else :
    print(int(A(c)/B))

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(f(min(b-1, n))

Submission status: Runtime Error

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

for i in range(N+1):
    num = math.floor(A*i/B) - A*math.floor(i/B)
    if num > maxnum:
        maxnum = num
    print(str(i) + ':' + str(num) + ' max is ' + str(maxnum))
print(maxnum)

Submission status: Runtime Error

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

ans = 0
pre = 0
for i in range(n+1):
  now = floor(a*x / b) - a * floor(x / b)
  if now > pre:
    ans = i
    pre = now
    
print(pre)

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
    print(ans)
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    max_c[c] = (a*n)//b - c
    print(max(max_c))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    max_c[c] = (a*n)//b - c
    print(max(max_c))

Submission status: Runtime Error

Solution code:
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c+1):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    print(max(max_c))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 200000:
    1 // 0

Submission status: Runtime Error

Solution code:
import sys
from copy import deepcopy
sys.setrecursionlimit(10**7)


def dfs(now):
    global ans
    if len(now) == N:
        tmp_ans = 0
        for a, b, c, d in query:
            a -= 1
            b -= 1
            if now[b] - now[a] == c:
                tmp_ans += d
        ans = max(tmp_ans, ans)
    else:
        for i in range(now[-1], M+1):
            tmp = deepcopy(now)
            tmp.append(i)
            dfs(tmp)


N, M, Q = map(int, input().split())  # N個の数列, 上限M, Q個のクエリ
query = [list(map(int, input().split())) for _ in range(Q)]

A = [1]
ans = 0
dfs(A)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(num):
    global N, ans, M
    n = len(num)
    if n == N:
        cnt = 0
        for a, b, c, d in con:
            a -= 1; b -= 1
            if num[b] - num[a] == c:
                cnt += d
        ans = max(ans, cnt)
    else:
        e = 1 if n == 0 else num[-1]
        for i in range(e, M + 1):
            dfs((*num, i))


N, M, Q = map(int, input().split())
con = [tuple(map(int, input().split())) for _ in range(Q)]

ans = 0
dfs(tuple())

print(ans)

Submission status: Runtime Error

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

mx = 0

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, N) for(int i=0; i<(N); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

vector<bool> seen;
vector<vector<int>> dist(2100, vector<int>(2100));

int main(){
    ll a, b, n;
    int x;
    cin >> a >> b >> n;
    x = min(b-1, n);
    int ans = (int) a*x/b - a * ((int) x/b);
    cout << ans << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main(){
	int a, b, n;
	cin >> a >> b >> n;
	
	int x = n;
	//printf("%d %d %d %d\n", a, b, n, x);
	int max_ = -1;
	for(int i = 0;i <= b; i++){
		if(x < 1)
			break;
		int t = a * x / b - a * (x / b);
		max_ = (max_ < t)?t:max_;
		//printf("%d %d\n", max_, x);
		x--;
	}
	printf("%d", max_);
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t = A * (X // B)
  if s -  t > a:
    a = s - t
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

m = min(b,n)
print(max(list(map(lambda y: keisan(a, b, y) ,range(1,m)))))

Submission status: Runtime Error

Solution code:
#-*- coding: utf-8 -*-
a,b,n = map(int,input().split())
if n>=b:
    n = b - 1
    print(int(a*n/b)-(a*n/b))
    exit():
else:
    print(int(a*n/b))
    exit():

Submission status: Runtime Error

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

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

print(max(list(map(lambda y: keisan(a, b, y) ,range(1,min(b, n))))))

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))
A = i[0]
B = i[1]
N = i[2]
a = -10 ** 20
for x in range(1, N+1):
  s = A * x // B
  t_0 = x // B
  t = A * t
  u = s - t
  if u > a:
    a = u
print(a)

Submission status: Runtime Error

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

if B > N:
    print(A*N//B)
else:
    print(A*(B-1)//B

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if B > N:
    print(A*N//B)
else:
    print(A*(B-1)//B-A*(b-1)//B)

Submission status: Runtime Error

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

x = list(range(1, N+1))

ans = -10**20
for i in x:
  y = math.floor(A*i/B) - A * math.floor(i/B)
  if y > ans:
    ans = y
print(y)

Submission status: Runtime Error

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

x = list(range(1, N+1))

ans = -10**20
for i in x:
  y = math.floor(A*i/B) - A * math.floor(i/B)
  if y > ans:
    ans = y
  elif y < ans:
    break
print(y)

Submission status: Runtime Error

Solution code:
from itertools import combinations_with_replacement


n,m,q = map(int,input().split())
num_lst = []
for i in range(q):
    num_lst.append(list(map(int,input().split())))
l = list(range(1,m+1))
A = list(combinations_with_replacement(l,n))

mx = 0
for now_A in A:
    score = 0
    for nums in num_lst:
        a,b,c,d = nums
        if now_A[b-1] - now_A[a-1] == c:
            score += d
    mx = max(mx,score)
print(mx)

Submission status: Runtime Error

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

x = list(range(1, N+1))

ans = -10**10
for i in x:
  y = math.floor(A*i/B) - A * math.floor(i/B)
  if y > ans:
    ans = y
  elif y < ans:
    break
print(y)

Submission status: Runtime Error

Solution code:
from itertools import product

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

A = [0, 1]
combnation = list(product(A, repeat=Q))
abcd.sort()

ans = 0
for comb in combnation:
    print(comb)
    comb_list = [abcd[i] for i, k in enumerate(comb) if k==1]
    check = True
    A = [0 for i in range(N+1)]
    amount = 0
    for a, b, c, d in comb_list:
        amount += d
        if A[a] == 0 and A[b] == 0:
            if A[a] == 0 and A[b] == 0:
                A[a] = 1
                A[b] = 1 + c
    
        elif A[a] == 0 and A[b] != 0:
            if A[b] - c >= 1:
                A[a] = A[b] - c
            else:
                check = False
                break
    
        elif A[a] != 0 and A[b] == 0:
            if c + A[a] <= M:
                A[b] = A[a] + c
            else:
                check = False
                break
        else:
            if A[b] - A[a] != c:
                check = False
                break
    
    if check and amount > ans:
        ans = amount
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
n,m,q=(int(i) for i in input().split())
l=[]
r=[i+1 for i in range(m)]
g=itertools.combinations_with_replacement(r,n)
point=0
def checker(x,l):
  p=0
  for i in range(len(l)):
    a,b,c,d=(l[i][j] for j in range(4))
    if x[b]-x[a]==c:
      p+=d
  return p
for i in range(q):
  a,b,c,d=(int(i) for i in input().split())
  a-=1
  b-=1
  l.append([a,b,c,d])
for i in g:
  p=checker(i,l)
  if p>point:
    point=p
print(point)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
MAX_VALUE = pow(10, 7)
result = 0
for i in range((N//MAX_VALUE)+1):
    x = np.array([])
    if i == 0:
        x = np.arange(min(N, B-1), min(N, MAX_VALUE)+1, B)
    else:
        x = np.arange(MAX_VALUE*i, min(N, MAX_VALUE*(i+1))+1, B)
    x = func(x)
    result = max(result, int(np.max(x)))

# 結果出力
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
MAX_VALUE = pow(10, 5)
result = 0
for i in range((N//MAX_VALUE)+1):
    x = np.array([])
    if i == 0:
        x = np.arange(min(N, B-1), min(N, MAX_VALUE)+1, B)
    else:
        x = np.arange(MAX_VALUE*i, min(N, MAX_VALUE*(i+1))+1, B)
    x = func(x)
    result = max(result, int(np.max(x)))

# 結果出力
print(result)

Submission status: Runtime Error

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

x=N
result=[]
for x in reversed(range(1,N+1)):
    ans=floor(A*x/B)-A*floor(x/B)
    result.append(ans)
    if len(result) == 1:
        maxr = ans 
    if len(result) > 1 max(result) == maxr:
        pass

print(max(result))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力の取得
A, B, N = list(map(int, input().split()))


def func(x: np.ndarray) -> np.ndarray:
    return np.floor(A*x/B) - A*np.floor(x/B)


# 求解処理
MAX_VALUE = pow(10, 5)
result = 0
for i in range((N//MAX_VALUE)+1):
    x = np.array([])
    if i == 0:
        x = np.arange(min(N, B-1), min(N, MAX_VALUE)+1, B)
    else:
        x = np.arange(MAX_VALUE*i, min(N, MAX_VALUE)+1, B)
    x = func(x)
    result = max(result, int(np.max(x)))

# 結果出力
print(result)

Submission status: Runtime Error

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

def fnc(x):
    return int((a*x)/b)-a*int((x/b))

ans = []

for i in range(min(x,n)):
    ans.append(fnc(i))

print(max(ans))

Submission status: Runtime Error

Solution code:
    #!/usr/bin/env python3
    import sys
    import math
     
    def solve(A: int, B: int, N: int):
     
        x = min(B-1, N)
        print(math.floor(A*x/B) - A*math.floor(x/B))
     
        return
     
     
    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: Runtime Error

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

Submission status: Runtime Error

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

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

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

import random
a,b,n=map(int,input().split())
def f(x):
    return int(a*x/b)-a*int(x/b)
if n<b:
    ans =f(n)
else:
    t = n
    u = b - 1
    v=min(t,u)
    ans=f(v)
print(ans)

Submission status: Runtime Error

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

A, B, N = map(int, input().split())
x = min(B-1, N)
print(A*x/B - A*(X/B))

Submission status: Runtime Error

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

def solve(A: int, B: int, N: int):

    x = min(B-1, N)
    print(math.floor(A*x/B) - A*math.floor(x/B)

    return


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

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

Submission status: Runtime Error

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

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Submission status: Runtime Error

Solution code:
def f(a, b, x):
  return int(a*x/b) - (a*int(x/b))
A, B, N = map(int, input().split())
print(f(A, B, min(B-1, N))

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
s=[]
s.append(0)
for x in range(N):
  t=int(A*x/B)-A*int(x/B)
  if t>max(s):
    s.append(t)
input(max(s))

Submission status: Runtime Error

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

def fnc(x):
    return int((a*x)/b)-a*int((x/b))

ans = []

for i in range(x):
    ans.append(fnc(i))

print(max(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
import time
a, b, n = map(int, input().split())
t1 = time.time()
x = np.array(list(range(n)))
print(max((np.floor(a * (x+1) / b) - a * np.floor((x+1)/b))))
t2 = time.time()
print("{}ms".format((t2-t1)*1000))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
from math import sqrt, floor

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


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

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

X = N
Y = min(B-1,N)

print(min(f(X),f(Y))

Submission status: Runtime Error

Solution code:
import math

A, B, N = map(int, input().split())
x = max(B-1, N)
print(math.floor((A*x)/B)-A*(x//B)

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
if b[2]>b[1]-1:
    check = math.floor((b[0]*(b[1]-1))/b[1]) - b[0]*math.floor((b[1]-1)/b[1])
else:
    check = math.floor((b[0]*b[2])/b[1]) - b[0]*math.floor(b[2]/b[1])
print(ans)

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
S = 0
n = N // B
r = N % B
if B > N:
    S = (A*N)//B
else:
    if  r == 0:
        S = (A*(N-1))//B - A * ((N-1)//B))
    elif r == B - 1:
        S = (A*N)//B - A * (N//B)
    else:
        S = (A*(n*B-1))//B - A * ((n*B-1)//B)

print(S)

Submission status: Runtime Error

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

import math as mt

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

    maxn = 0
    
    elif N >= B:
        maxn = mt.floor(A*(B-1)/B) - A*mt.floor((B-1)/B)
    else:
        maxn = mt.floor(A*N/B) - A*mt.floor(N/B)
    
    print(maxn)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
S = 0
n = N // B
r = N % B
if B > N:
    S = (A*N)//B
else:
    if  r == 0:
        S = (A*(N-1))//B - A * ((N-1）//B))
    elif r == B - 1:
        S = (A*N)//B - A * (N//B)
    else:
        S = (A*(n*B-1))//B - A * ((n*B-1)//B)

print(S)

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)
    else:
        s=math.floor(a*((1/b)-i//b))
    if s>max:
        max=s"""
        max=math.floor(a*n-1/b)
print(max)

Submission status: Runtime Error

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