Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

Solution code:

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
msi = lambda: map(str, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

A, B, N = mii()

ans = 0

x = B
ans = max(ans, A*x//B - A*(x//B))
x -= 1
ans = max(ans, A*x//B - A*(x//B))

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
def func(x):
    return int((A*x)/B) - A * int(x/B)

if N <= B:
    print(func(N))
else:
    print(A-1)

Submission status: Wrong Answer

Solution code:
def floor(x):
    import math
    return math.floor(x)

if __name__ == '__main__':
    a, b, n = map(int, input().split())
    m = 0
    for x in range(1, n+1):
        p = floor(a*x/b) - floor(x/b)
        x += 1
        if m <= p:
            m = p
    print(m)

Submission status: Wrong Answer

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*(1/b)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n // b * b - 1 == -1:
    tmp = n
else:
    tmp = n // b * b - 1
ans = int(a * tmp / b) - a * int(tmp / b)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n<b:
  ans=int(a*n/b)-a*int(n/b)
if n==b:
  ans=int(a*(n-1)/b)-a*int((n-1)/b)
if n>b:
  r=n%b
  ans=int(a*r/b)-a*int(r/b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
l = list(input().split(" "))
a = int(l[0])
b = int(l[1])
n = int(l[2])
def f(x):
  return math.floor(x)
c = f(a/b) - a*f(1/b)
for i in range(2,n):
  d = f(a*i/b) - a*f(i/b)
  if c >= d:
    c = c
  else:
    c = float(d)
print(str(c))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
A, B, N = map(int, input().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ps = make_divisors(B - 1)
res = (A * N) // B - A * (N // B)
for i in ps:
  if N < i: continue
  for j in range(1, 10 ** 4 + 1):
    x = i * j
    res = max(res, (A * x) // B - A * (x // B))
for x in range(1, min(N, 10 ** 4)):
  res = max(res, (A * x) // B - A * (x // B))
print(res)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from sys import setrecursionlimit
import math

a,b,n = map(int,stdin.readline().rstrip().split())

print(math.floor(a*n/b)-a*math.floor(n/b))

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
d = N//B
x = (d+1)*B
while x > N:
    x -= 1


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

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,N=MI()
    y = (N+1+B-1)//B
    x = y*B-1
    x = min(x,N)    

    def f(x):
        return (A*x)//B - A*(x//B)
    # print(x,y)#####
    print(f(x))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

ans = 0
for i in range(min(A+10, N+1)):
    ans = max(ans, calc(i))
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = map(int,input().split())
def func(x):
    return int((A*x)/B) - A * int(x/B)

if N < B:
    print(func(N))
else:
    print(A-1)

Submission status: Wrong Answer

Solution code:
import math

def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization
def factor(N):
    ans = []
    for i in range(1,int(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

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

b = factor(B-1)

ans = -1e9
for i in b:
    if i <= N:
        ans = max(ans,math.floor(A*i/B)-A*math.floor(i/B))

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n = [int(x) for x in input().split()]
import math,bisect
i = n
x = math.floor(a*i/b)-math.floor(i/b)*a
print(x)

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

A,B,N=map(int,input().split())
def main(x):
    #print(x,int(A*x/B),A*int(x/B))
    return(int(A*x/B)-A*int(x/B))
st=1
ed=N
C=max(main(st),main(ed))
while ed-st>2:
    #print(ed,st)
    mid1=(st*2+ed)//3
    mid2=(st+ed*2)//3
    C0=main(st)
    C1=main(mid1)
    C2=main(mid2)
    C3=main(ed)
    C=max(C,C0,C1,C2,C3)
    if C0==C:
        ed=mid2
    elif C1==C:
        ed=mid2
    elif C2==C:
        st=mid1
    elif C3==C:
        st=mid1
    else:
        st+=1
        ed-=1
if ed-st==2:
    C=max(main(st),main(st+1),main(ed),C)
print(C)

Submission status: Wrong Answer

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

if a==1:
  print(0)
else:
  print((a*n)//b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(1000000):
    x=(hi+low)//2
    t0=floor(a*x/b)-a*floor(x/b)
    t1=floor(a*(x+1)/b)-a*floor((x+1)/b)
    if t1>=t0:
        low=x
    else:
        hi=x
print(max(t1,t0))

Submission status: Wrong Answer

Solution code:
abn = input().split(" ")
a = int(abn[0])
b = int(abn[1])
n = int(abn[2])
x = 1
m = 0
mx = 1
while x <= n:
  f1 = (a*x)/b
  f2 = x/b
  f = int(f1) + a*int(f2)
  if f >= m:
    m = f
    mx = x
  x += 1
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    if a == b == n and not a == b == n == 1:
        print(a)
    elif n == 1:
        print(n)
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

ans = 0
for i in range(min(x+1, 10**6), max(x+1, 10**6)):
    ans = max(ans, a*i//b - a*(i//b))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A,B,N=pin()
    def f(A,B,x):
        t=(A*x)//B
        s=x//B
        return t-A*s
    xans=(N//B)*B+(B-1)
    if xans>N:xans=N
    print(f(A,B,xans))
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
import math


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


def solve(A, B, N):
    k = N // B
    x = max(B * k - 1, 0)
    y0 = math.floor(A * N / B) - A * math.floor(N / B)
    y1 = math.floor(A * x / B) - A * math.floor(x / B)
    return max(y0, y1)

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Submission status: Wrong Answer

Solution code:
from math import floor
def seq(a, b, x):
    return int(floor((a*x)/b)) - int(a*floor(x/b))
def bs(a, b, n):
    low = 1
    high = n
    ans = -1
    while low<=high:
        mid = low + (high-low)//2
        if seq(a, b, mid)>=seq(a, b, mid-1):
            low = mid+1
            ans = mid
        else: high = mid-1
    return ans
a, b, n = map(int, input().split())
print(seq(a, b, bs(a, b, n)))

Submission status: Wrong Answer

Solution code:
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

A,B,N = Ints()

x = min(int(A*N/B),A-1)
#print(x - A*int(x/A))

ans = 0
n = 1
x = -int(-B*n/A)

while x<=N and n <= A-1:
    ans = max(ans, int(A*x/B)-A*int(x/B))
    n += 1
    x = -int(-B*n/A)
print(ans)

Submission status: Wrong Answer

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

for i in range(1,n+1):
  x = int(a*i/b) - a*int(i/b) #これの最大値？
  if x > ans:
    ans = x'''

if n%b == 0: #最後のあまりが0だったら
  print(int(a*(n-1)/b) - a*int((n-1)/b))
else:
  print(int(a*n/b) - a*int(n/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
b = list(map(int,input().split()))
ans=0
check=0
for i in range(100000):
    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
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import random
import copy
import math
def main():
     A,B,N = map(int,input().split())
     if min(B,N) == N:
          x = min(B,N)-0.000000001
          ma = math.floor(A*x/B)-A*math.floor(x/B)
          x = N
          ma = max(ma,math.floor(A*x/B)-A*math.floor(x/B))
     else:
          ma = A-1
     print(ma)
                    
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=-float("inf")
i=0
while True:
    x=b*i-1
    i+=1
    if x>n:
        ans=int((a*n)/b)-a*int(n/b)
        print(ans)
        break
    if ans<int((a*x)/b)-a*int(x/b):
        ans=int((a*x)/b)-a*int(x/b)
    else:
        print(ans)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

X = min(B-1, N)
# ans = A * math.floor(X/B) - math.floor((A*X)/B)
ans = A * ((X/B) %1) - (A*X/B)%1
print(int(ans))

Submission status: Wrong Answer

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

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

elif A < B:
    if N < B:
        print(int(A/B*N))
    else:
        print( int(A/B*(B-1)))

Submission status: Wrong Answer

Solution code:
#abc165_d.py
import math
I = input().split()
A = int(I[0])
B = int(I[1])
N = int(I[2])

Max = 0
y = 0
kou1 = 0
kou2 = 0


for i in range(1,N+1):
    if ((A*i)//B != kou1):
        kou1 = (A*i)//B
    if (i//B != kou2):
        kou2 = i//B
    if (Max < (kou1 - kou2)):
        Max = (kou1 - kou2)

print(Max)

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
ans = 0
for i in range(n+1,max(0,n-10**7),-1):
    ans = max(ans,((a * i)//b -a * (i//b)))
print(ans)

Submission status: Wrong Answer

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

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

ans = 0
for i in range(1,min(A+1, N+1)):
    ans = max(ans, calc(i))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
start=0
end=n
ans=0
while start<=end:
	mid=(start)+(end-start)//2
	ans1=math.floor((a*mid)/b)-(a*math.floor(mid/b))
	ans2=math.floor((a*start)/b)-(a*math.floor(start/b))
	ans3=math.floor((a*end)/b)-(a*math.floor(end/b))
	ans=max(ans,ans1)
	ans=max(ans,ans2)
	ans=max(ans,ans3)
	if ans2<=ans3:
		start=mid+1
	else:
		end=mid-1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for x in range(max(n-a, 0), n+1):
    tmp = math.floor((a*x)/b) - (a * math.floor(x/b))
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
import math

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

tmp = math.floor(A*N/B)-A*math.floor(N/B)
print(tmp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


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

result = 0
for i in range(1, N+1, B):
    i -= 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: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import random
import copy
import math
def main():
     A,B,N = map(int,input().split())
     if min(B,N) == N:
          x = min(B,N)-0.000000000001
          ma = math.floor(A*x/B)-A*math.floor(x/B)
          x = N
          ma = max(ma,math.floor(A*x/B)-A*math.floor(x/B))
     else:
          ma = A-1
     print(ma)
                    
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
if n==1:
  x=n#pass
elif n<b:
  x=n
else:
  x=n%b
  if x==0:
    x=b-1
print(int(a*x/b)-a*int(x/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


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

high = n
low = 0
while high - low >= 1:
    mid_left = high/3+low*2/3
    mid_right = high*2/3+low/3
    if f(mid_left) <= f(mid_right):
        low = mid_left
    else:
        high = mid_right
print(f(int(high)))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, n-4, -1):
    f1 = (a*i)//b
    f2 = i//b
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

import math
print(math.floor(a*n/b) - a*math.floor(n/b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

m = -1

for x in range(1, N+1):
    res = math.floor(A * x / B) - A * math.floor(x / B)
    if res > m:
        m = res
    else:
        break

print(m)

Submission status: Wrong Answer

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from math import floor
    a,b,n = readInts()
    p = b-1 if b-1 <= n else n-1
    if a == b == n and not a == b == n == 1:
        print(a)
    else:
        print(floor(a*p//b) - a*floor(p//b))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N>B:
    x = B -1
else:
    x = N
F1 = (A*x)//B
F2 = A * (x//B)
S = F1 - F2
L = S
K = 0
while (L>K):
    L = S
    x -= 1
    F1 = (A*x)//B
    F2 = A * (x//B)
    S = F1 - F2
    K = S
ans = max(L,K)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def func(x):
    return int(A * x * B ** -1) - A * int(x * B ** -1)

ub = N
lb = 0
ans = func(N)
while ub - lb > 1:
    mid = (ub + lb) // 2
    v = func(mid)
    if ans < v:
        lb = mid
        ans = v
    else:
        ub = mid

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,N = [int(i) for i in input().split()]
floor = lambda A,B,x: (A*x)//B - A*(x//B)
lb = 0
ub = N
for _ in range(50):
    mid = (lb + ub + 1) // 2
    c = floor(A, B, mid)
    cn = floor(A,B,mid-1)
    if c > cn:
        lb = mid
    else:
        cp = floor(A,B,mid+1)
        if c < cp:
            ub = mid
        else:
            break
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def seq(a, b, x):
    return (a*x)//b - a*(x//b)
def bs(a, b, n):
    low = 1
    high = n
    ans = -1
    while low<=high:
        mid = low + (high-low)//2
        if seq(a, b, mid)>=seq(a, b, mid-1):
            low = mid+1
            ans = mid
        else: high = mid-1
    return ans
a, b, n = map(int, input().split())
print(seq(a, b, bs(a, b, n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(1, min(x+1, 10**5)):
    ans = max(ans, a*i//b - a*(i//b))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
A,B,N=list(map(int,input().split()))
while True:
    if N%B!=0:
        print(math.floor(A*N/B)-(A*math.floor(N/B)))
        break
    elif N==0:
        print(0)
        break
    else:
        N-=1

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


def calc(x):
    return ((a * x) // b) - (a * (x // b))


a, b, n = sp()
# low, high = 1, n
# answer, index = -inf, 0
# # while low <= high:
# #     mid = (low + high) // 2
# #     temp = calc(mid)
# #     if temp > answer:
# #         answer = mid
# #         low = mid + 1
# #     else:
# #         high = mid - 1
# for i in range(1, n+1):
#     print(calc(i), i)
#     if calc(i) > answer:
#         index = i
#         answer = calc(i)
out(calc(n))

Submission status: Wrong Answer

Solution code:

s = input().split()
a = int(s[0])
b = int(s[1])
n = int(s[2])

l = list()

for x in range(n):
    ans = a*x //b - a*(x//b)
    l.append(ans)

print(max(l))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
ans = 0
for i in range(n+1,n-10**7,-1):
    ans = max(ans,((a * i)//b -a * (i//b)))
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, n-1, -1):
    f1 = (a*i)//b
    f2 = i//b
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

print(math.floor((b-1)*a/b))

Submission status: Wrong Answer

Solution code:
import math

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


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


_max = calc(A, B, 0)
for _x in range(1, N + 1):
    _temp = calc(A, B, _x)
    # print(_x, _max, _temp)
    if _temp == 0:
        break
    elif _temp > _max:
        _max = _temp

# print('answer')
print(_max)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0
for x in range(max(n-a-1, 0), n+1):
    tmp = math.floor((a*x)/b) - (a * math.floor(x/b))
    if ans < tmp:
        ans = tmp

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n= list(map(int, input().split()))
ma=0
for i in range(10000):
    ma=max(int((a*i/b)//1-a*((i/b)//1)),ma)
    ma=max(int((a*(n-i)/b)//1-a*(((n-i)/b)//1)),ma)
print(ma)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B,N=map(int,input().split())

num=N//B
if num==0:
    n=N
else:
    n=B*num-1

temp1=(A*n)/B//1
temp2=A*((n/B)//1)

print(temp1-temp2)

Submission status: Wrong Answer

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

for i in range(1,n+1):
  x = int(a*i/b) - a*int(i/b) #これの最大値？
  if x > ans:
    ans = x'''

print(int(a*n/b) - a*int(n/b))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

def resolve():
    a,b,n= map(int, input().split())
    if n > b:
        x = (n + b - 1) // b * b + 1
    else:
        x = n
    print(floor(a * x / b) - a * floor(x / b))

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

#for x in range(n+1):
x=b-1
ans=int(a*x/b)-a*int(x/b)
print(ans)

Submission status: Wrong Answer

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

A, B, N = map(int, input().split())
a = min(N, B)
print(f(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,n=map(int,input().split())
x_kouho=[]
count=1
while count<=n//b:
  x_kouho.append(b*count-1)
  count+=1
if not x_kouho:
  x_kouho.append(n)

res=0
for i in range(0,len(x_kouho)):
  keep=x_kouho[i]
  kept=(a*keep)//b-a*(keep//b)
  if kept>res:
    res=kept
print(res,x_kouho)

Submission status: Wrong Answer

Solution code:
a, b, n = list(map(int, input().split()))
if b <= n:
    k = n // b
    x = b * k - 1
else:
    x = n

print( a * x // b + a * int(x // b) )

Submission status: Wrong Answer

Solution code:
def naive(a, b, n):
	ans = 0
	for i in range(1, n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

def main(a, b, n):
	ans = 0
	tmp = []
	for i in range(max(n + 1 - a - 1, 1), n + 1):
		ans = max(ans, int((a * i) / b) - a * int(i / b))
	return ans

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

Submission status: Wrong Answer

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

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

if n < b:
    print(f(n))
else:
    x = n - (n%b+1)
    print(max(f(n), f(x)))

Submission status: Wrong Answer

Solution code:
a, b, n = map(int, input().split())
ans = -float('inf')
for i in range(n, n-2, -1):
    f1 = (a*i)//b
    f2 = i//b
    tmp = f1-(a*f2)
    if ans < tmp:
        ans = tmp
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def D():
    A, B, N = map(int, input().split())
    x = N % B
    print(A*x//B - A*(x//B))
D()