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:
import math
import numpy as np

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

ApB = A / B

ans = 0
for x in np.array(range(N)) + 1:
	t = math.floor(ApB * x) - A * math.floor(x/B)
	if (t >= ans):
		ans = t
	else:
		print(ans)
		exit()

print(ans)

Submission status: Runtime Error

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

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

ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
N=int(input())
s=[]
for x in range(0,N+1):
    y=int((A*x)/B)
    z=int(x/B)
    p=y-A*z
    s.append(p)
print(max(s))

Submission status: Runtime Error

Solution code:
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, B, 1)
print(fun(x))
print(int(max(fun(x))))

Submission status: Runtime Error

Solution code:
#A,B,N=input().split(" ")
A=int(input())
B=int(input())
N=int(input())
s=[]
for x in range(0,N+1):
    y=int((A*x)/B)
    z=int(x/B)
    p=y-A*z
    s.append(p)
print(max(s))

Submission status: Runtime Error

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

def main():
    a,b,n = map(int,input().split())
    l = gcd(a,b)
    print(a*min(n,(b-1))//b-a*(min(b-1,n)//b))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
A,B,N = (int(i) for i in input().split())
max_num = -10**100
tmp_num = 0
cnt = 1
flg = False
while flg  == False:
  tmp_num = math.floor(A*cnt/B) - A*math.floor(cnt/B)
  #print(tmp_num)
  if tmp_num > max_num :
    max_num = tmp_num
    cnt += 1
  else:
    flg = True
print(max_num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

c = b-1

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
i=0
A=0
B=0
C=b[1]
max = b[2]//b[1]
if max==0:
    for i in range(b[2]+1):
        if b[2]-i <0:
            break
        check = math.floor((b[0]*(b[2]-i))/b[1]) - b[0]*math.floor((b[2]-i)/b[1])
        if check > ans:
            ans=check

else:
    for i in range(1,max+1):
        A=b[1]-1
        B=b[1]+1
        check = math.floor((b[0]*A)/C) - b[0]*math.floor(A/C)
        if check > ans:
            ans=check
        check = math.floor((b[0]*B)/C) - b[0]*math.floor(B/C)
        if check > ans:
            ans=check
        B[1]+=b[1]
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import sys
    import heapq
    input = sys.stdin.readline
    A,B,N=map(int,input().split())
    Z=[0]*(N+1)
    for x in range(N+1):
        Y=int(A*x/B)-A*int(x/B)
        Z[x]=-1*Y
    heapq.heapify(Z)
    result=-1*heapq.heappop(Z)
    print(result)    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
x = int(input())
m = 100
count = 0
while(m<x):
    m += math.floor(m/100)
    count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = 1
m = 0
while x <= b:
    m_x = (x/b) - (x//b)
    if m_x > m:
        i = x
        m = m_x
    x += 1
w = 0
while x > n:
    x = (n//b) + i - w
    w += 1
ans = ((a*x)//b) - (a*(x//b))
print(int(ans))

Submission status: Runtime Error

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

t=0
xx=0
l=[-1]*(b+1)
p=1
if n>b and b>1:
   while t == 0 and xx <= n:
      xx += 1
      c=a*xx%b
      if l[c]==-1:
         l[c]=xx
      else:
         t=1
   while t>-1:

      if l[p]>-1:
         t=-2
         x=l[p]
      p+=1
else:
   x=n
print(a*x//b-a*(x//b))

Submission status: Runtime Error

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

result = []
if n < b:
    print(math.floor(a * n / b) - a * math.floor(n / b))

else:
    i = n
    while (n - i) == b - 1:
        result.append(math.floor(a * i / b) - a * math.floor(i / b))
        i = i - 1
    print(max(result))

Submission status: Runtime Error

Solution code:
from math import floor
A,B,N = map(int,input().split())
if N <= B:
    print(floor(A*N/B)-A*floor(N/B))
else:
    print("1"*"1")
    print(max(floor(A*N/B)-A*floor(N/B),floor(A*(B+1)/B)-A*floor((B+1)/B)))

Submission status: Runtime Error

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

answer = 0
if b-1 > n:
    x = n
else:
    x = (n // (b-1)) * (b-1)
answer = (a*x)//b - a*(x//b)

print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if n>b:
    for x in range(b-1,n):
        y=a*x//b-a*(x//b)
        l.append(y)

else:
    for x in range(1,n):
        y=a*x//b-a*(x//b)
        l.append(y)


print(max(l))

Submission status: Runtime Error

Solution code:
import math
def func(i):
    return math.floor(a * i * 1.0 / b) - a * math.floor(i * 1.0 / b);
 
a, b, n = map(int, input().split())
 
print (max(func(b), func(n))

Submission status: Runtime Error

Solution code:
import math 

a, b, n = map(int, input().split())
if n < b:
    print(math.floor(a*n/b))
else:
    ls = [math.floor(a*i/b)-(a*math.floor(i/b)) for i in range(abs(n-5), n+1)]
    print(max(ls))

Submission status: Runtime Error

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

x = 0
ans = 0
if n < b:
    x = n
    ans = math.floor(a*x/b) - a * math.floor(x/b)
else:
    x = n - 1
    ans = math.floor(a*x/b) - a * math.floor(x/b)
print(ans)

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
M = [0]*(n+1)
for i in range(n+1):
    score = int(a*i/b) - a*int(i/b)
    M[i] = score

print(max(M))

Submission status: Runtime Error

Solution code:
A,B,N = map(int, input().split())
result=0
for x in range(N+1):
    f=int(A*X/B)-A*(int(x/B))
    if f>=result:
        result=f
print(result)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

a, b, n = map(int, input().split())
arr = np.arange(1, n+1)

res_arr = np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))(np.arange(1, n+1))

print(np.nanmax(res_arr))
# np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))( np.arange(1, n+1)).max()

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

ApB = A / B

ans = 0
for x in np.array(range(N)) + 1:
	t = math.floor(ApB * x) + A * math.floor(x/B)
	if (t >= ans):
		ans = t
	else:
		print(ans)
		exit()

print(ans)

Submission status: Runtime Error

Solution code:
a,b,n = map(int, input().split())
M = [0]*(n+1)
for i in range(n+1):
    score = int(a*i/b) - a*int(i/b)
    M[i] = score

print(max(M))

Submission status: Runtime Error

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

if b-1>n:
  start = n
else:
  start = (b-1)*(n//(b-1))

ans = 0

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
max=0
for x in range(1,n):
  co=abs(math.ceil((a*x)/b)-(a*math.ceil(x/b)))
  if(co>max):
    max=c
print(max)

Submission status: Runtime Error

Solution code:
q = min(b-1,n)
ni = int(a*q/b)
if ni > nmax:
        nmax = ni
print(nmax)

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.reverse()
print(ANS[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

x = min(b. n)
print(int(a * x / b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

a, b, n = raw_input().split();
a = int(a);
b = int(b);
n = int(n);

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

Submission status: Runtime Error

Solution code:
import math

A, B, N = map(int, input().split())
res = math.floor(((A * 1) / B)) - A * math.floor((1 / B))
l = []
for i in range(2, N + 1):
    l.append(math.floor(((A * i) / B)) - A * math.floor((i / B)))
print(max(l))

Submission status: Runtime Error

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

t=0
xx=0
l=[-1]*b
p=1
if n>b:
   while t == 0 and xx <= n:
      xx += 1
      c=a*xx%b
      if l[c]==-1:
         l[c]=xx
      else:
         t=1
   while t>-1:

      if l[p]>-1:
         t=-2
         x=l[p]
      p+=1
else:
   x=n
print(a*x//b-a*(x//b))

Submission status: Runtime Error

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

if b == 1:
    print(0)
elif n < b:
    print(math.floor(a*n/b)+math.floor(n/b))
else:
    print(math.floor(a*(b-1)/b)+math.floor((b-1)/b))

Submission status: Runtime Error

Solution code:
#include <iostream>
typedef long long ll;
using namespace std;

int main(void)
{
  ll a, b, n;
  cin >> a >> b >> n;

  if (n>=b){
    cout << a*(b-1)/b << endl;
  }else {
    cout << a*n/b << endl;
  }
  
  return 0;
}

Submission status: Runtime Error

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

l = None
if B <= N:
    l = [0]*(B-1)
else:
    l = [0]*N
#print('len: ', len(l))



for x in range(1, len(l) + 1):
    l[x-1] = ((A*x)//B) - A*(x//B)

print(max(l))



'''m = 0
for x in range(1, N+1):
    j =  ((A*x)//B) - A*(x//B)
    m = max(m,j)


print('MAX',m)
'''

Submission status: Runtime Error

Solution code:
import math
import numpy as np

a, b, n = map(int, input().split())
arr = np.arange(1, n+1)

print(np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))( np.arange(1, n+1)).max())
# np.vectorize(lambda x: math.floor(a*x / b) - a * math.floor(x / b))( np.arange(1, n+1)).max()

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,n = m()

if a > b:
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

"""


a,b,n = m()

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

Submission status: Runtime Error

Solution code:
import math

a,b,n = map(int,input().split())
cnt = 0
t = 0
if n<=b:
    print(math.floor(a*n/b))
    exit()
for i in range(math.floor(n/b)):
    t = math.floor(a*(b(i+1))/b)-a*i
    print("a")
    if cnt <= t:
        cnt=t
            
print(cnt)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e5 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  ll a = in() , b = in() , n = in() ;
  ll l = 0 , r = n , ans = 0 ;
  while(l < r)
   {
     ll mid = l + r + 1 >> 1 ;
     if((a * mid) / b - a * (mid / b) >= ans) l = mid ;
     else r = mid - 1 ;
   }
  cout << (a * r) / b - a * (r / b) << endl ;
  return 0 ;
}
/*
*/

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
def fun(x):
    return np.floor(A*x/B)-A*np.floor(x/B)

A, B, N = map(int,input().split())
x = np.arange(0, N+1, 1)
print(int(max(fun(x))))

Submission status: Runtime Error

Solution code:
from math import gcd



a,b,n=map(int,input().split())
t=a*b//gcd(a,b)
if a==1:
    print(0)
    exit()

ans=[]

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


print(max(ans))

Submission status: Runtime Error

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

else:
    for x in range(0,N+1,B-1):
        floor = int(A*x / B) - A * int(x/B)
        if x == 0:
            max = floor
        else:
            if floor >= max:
                max = floor

            
print(max)

Submission status: Runtime Error

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

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

print(int(max(y3)))

Submission status: Runtime Error

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

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:
    print(func(n))
else:
    a = [i for i in range(n) if i%b==b-1]
    print(func(max(a)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if N>B:
    x = B -1
else:
    x = N
D = []

if N > 10:
    w = N % 10
else:
    w = N-1
for i in range(w):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

Submission status: Runtime Error

Solution code:
import math


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

result = 0
candidates = []
for i in range(0, N+1, B):
    if i <= 1:
        continue
    i -= 1
    candidates.append(i)
i = candidates[-1]
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: Runtime Error

Solution code:
import numpy as np

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

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

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

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
def floor(x):
  return (x//1)
list = []
for x in range(N+1):
  if x % B != 0:
    list.append(floor((A*x)/B)-(A*floor(x/B)))
print(int(max(list)))

Submission status: Runtime Error

Solution code:
A,B,N = map(int,input().split())
x,max = 0,0
while x <= N:
  ans = a(A,B,x)
  if max <= ans:
    max = ans
  x += 1
print(max)

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

Submission status: Runtime Error

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

x = np.arange(1, max(10**6,N+1))
print(int(np.max(np.floor(A*x/B)-A*np.floor(x/B))))

Submission status: Runtime Error

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

t=0
xx=0
l=[0]*b
p=1
if a<b:
   while t == 0 and xx <= n:
      xx += 1
      c=a*xx%b
      if l[c]==0:
         l[c]=xx
      else:
         t=1
   while t>-1:

      if l[p]>0:
         t=-2
         x=l[p]
      p+=1



else:
   x=n
print(a*x//b-a*(x//b))

Submission status: Runtime Error

Solution code:
import numpy as np

num_list = list(map(int, input().split()))
vec = np.array(range(num_list[2]+1))

vec = np.floor(num_list[0]*vec/num_list[1])-num_list[0]*np.floor(vec/num_list[1])

print(int(max(vec)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(int(ans))

Submission status: Runtime Error

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

k=int(input())
a,b=map(int,input().split())
c=a-b
if(c>=k-1):
    print("OK")
elif(a%k+c>=k):
    print("OK")
else:
    print("NG")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a,b,n=map(int,input().split())
l=[]
if n>=b:
    x=b-1
else:
    x=n
print(math.floor((a*x)/b)-a*math.floor(x/b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    a = kwargs["a"]
    b = kwargs["b"]
    n = kwargs["n"]

    R = [0 for i in range(b)]

    for i in range(min(b, n) + 1):
        R[i] = a * i // b - a * (i // b)

    res = max(R)
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    #kwargs["n"] = cin[0]
    #kwargs["n"], kwargs["k"] = cin
    #kwargs["n"] = [int(i) for i in cin][0]
    kwargs["a"], kwargs["b"], kwargs["n"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N>B:
    x = B -1
else:
    x = N
D = []

for i in range(N//2):
    F1 = (A*(x-i))//B
    F2 = A * ((x-i)//B)
    S = F1 - F2
    D.append(S)

ans = max(D)
print(ans)

Submission status: Runtime Error

Solution code:
x=input().split(" ")
N=int(x[0])
M=int(x[1])
if N%2==0:
  for i in range(M):
    print(i+2,M*2+1-i)
else:
  for i in range(M):
    print(i+1,M*2-i)

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B, N = LI()
ans = math.floor(A * N / B)
if N > B:
    ans = max(ans, math.floot(A * (B - 1) / B))
print(ans)

Submission status: Runtime Error

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

if N <B:
	print(int(math.floor(A*N/B)))
	exit()

if N%B == 0:
	nagasa = int(N/B)
else:
	nagasa = int(math.floor(N/B))+1

k = [0]*nagasa

for i in range (1, nagasa+1):
	k[i-1] = i*B-1

k[nagasa-1] = N
    
boom=0

for i in range (0, nagasa):
	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 main():
    a,b,n = map(int,input().split())
    if b>n:
        print(int(a*(n/b-n//b)))
    else:
        print(int(a*((b-1)/b))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

left, right = 0, n
while right - left > 1:
  x = mid = (left + right) // 2
  # val = a * x // b - a * (x // b)
  val = x * (a - 1) / b + 1
  if val > 0:
    left = mid
  else:
    right = mid

print(int(val))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

def fl(number):
    return math.floor(number)

a,b,n = map(int,input().split())
x = list(range(1,n+1))
ma = 0

for i in x:
    c = fl(i/b)
    tmp = fl((a*i)/b)-(a*c)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Runtime Error

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

tmp_pre = 0
for i in range(1, N+1):
  tmp = math.floor(A*i/B) - A*math.floor(i/B)
  if tmp > tmp_pre:
    tmp_pre = tmp
print(int(tmp_pre))

Submission status: Runtime Error

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

#print(A)
#print(B)
#print(N)

ret = 0
for i in range(1, N+1):
  #print(i)
  #temp = math.floor(A * i / B) - A * math.floor(i / B)
  #print(temp)
  #if temp > ret:
    #ret = temp

temp = math.floor(A * N / B) - A * math.floor(N / B)
if temp > ret:
  ret = temp

  
print(ret)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

Solution code:
import math
A,B,N= map(int,input().split())
x=[]
AB=A/B
if N<=B:
    #x.append(math.floor(AB*N-1)-A*(N//B)
    print(math.floor(AB*N-1)-A*(N//B)
else:
    print(math.floor(AB*B-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

if N<B-1:
    print(f(N))
else:
    print(f(B-1))

Submission status: Runtime Error

Solution code:
import math.floor
a,b,n=map(int,input().split())
x=1
while x>0 and x<n:
  max1= math.floor((a*x)/b) - a * math.floor(x/b)
  x+=1
print(max1)

Submission status: Runtime Error

Solution code:
def main():
  import math
  a, b, n = map(int, input().split())
  gcd = math.gcd(a, b)
  a = a / gcd
  b = b / gcd
  ans = 0
  for i in range(min(b+1, n+1)):
    tmp = math.floor(a*i/b) - a*math.floor(i/b)
    if tmp > ans:
      ans = int(tmp)
  print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import math
a,b,n=map(int,input().split())
x=1
while x>0 and x<n:
  max1= math.floor((a*x)/b) - a * math.floor(x/b)
  x+=1
print(max1)

Submission status: Runtime Error

Solution code:
import math

A, B, N = map(int,input().split())
bst = -pow(10, 10)

for i in range(N+1):
    if((floor((A*i)/B) - A*floor(i/B)) > bst):
        bst = floor((A*i)/B) - A*floor(i/B)

print(bst)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

a, b, n = map(int, input().split())
x = np.arange(1,n+1)
fx = (x*a)//b - (x//b)*a
print(np.max(fx))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
A, B, N = map(int, input().split())
ans = [None]*(N)
for i in range(1,N+1):
    a = math.floor((A*i)/B)
    b = math.floor(i/B)
    ans[i-1] = a-A*b
print(max(ans))

Submission status: Runtime Error

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

# floor( Ar / B ) : r = 0..min(B-1,N%B)

r = N if N < B else r = B-1

print( A*r // B )

Submission status: Runtime Error

Solution code:
import math.floor
a,b,n=map(int,input().split())
x=1
while x>0 and x<n:
  max1= math.floor((a*x0)/b) - a * math.floor(x/b)
  x+=1
print(max1)

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:
a, b, n = map(int, input().split())
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Submission status: Runtime Error

Solution code:
import math
A,B,N = mips()
K = N-1
print(max(math.floor(A*N/B)-A*math.floor(N/B),math.floor(A*K/B)-A*math.floor(K/B),0))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,N=map(int,input().split())
result=0
for x in range(0,n+1):
	a=int(A*x/B)-A*int(x/B)
	if a>result:
		result=a
print(result)