Problem:


Score : 400 points

Problem Statement

Given are integers A, B, and N.

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

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

Constraints

1 ≤ A ≤ 10^{6}

1 ≤ B ≤ 10^{12}

1 ≤ N ≤ 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B N

Output

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

Sample Input 1

5 7 4

Sample Output 1

2

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

Sample Input 2

11 10 9

Sample Output 2

9



Sample input:
5 7 4


Sample output:
2

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

A, B, N = map(int, input().split())
print(abs(A-B)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

def fl(a,b,x):
	x=math.floor(a*x/b)
	y=a*math.floor(x/b)
	return x-y
	


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

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

# for i in range(0,n,b):
# 	ans=fl(a,b,i)
# 	if ans> b_ans:
# 		b_ans=ans
# if i<n:
# 	ans=fl(a,b,n)
# 	if ans> b_ans:
# 		b_ans=ans
print(b_ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

a, b, n = [int(i) for i in input().split()]

if n > b-1+((b-a)/a):
  ans = (a*(b-1+((b-a)/a)))//b - a*((b-1+((b-a)/a))//b)
  print(ans)
  quit()

ans = (a*n)//b - a*(n//b)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor

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

for x in range(0, n):
    result = floor(a*x)/b - a*floor(x/b)

print(floor(result))

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  # right=n
  # ans=math.floor(a*right/b)-a*math.floor(right/b)
  # left=0
  # while left<=right:
  #   half=(left+right)//2
  #   _ans=math.floor(a*half/b)-a*math.floor(half/b)
  #   if _ans==ans:
  #     return ans
  #   elif _ans>ans:
  #     right=half-1
  #     ans=_ans
  #   else:
  #     left=half+1

  ans=int(a*1/b)-a*int(1/b)
  x=int(math.sqrt(n))
  for i in range(max(0,n-x-3),n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

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

def solve(A: int, B: int, N: int):
    max_b = 0
    for x in range(min(N+1,1000000)):
        max_b = max(max_b, math.floor(A*(x/B-x//B)))
    print(max_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: Wrong Answer

Solution code:
def f1(a, b, x):
  return int(a * x / b)

def f2(a, b, x):
  return a * f1(1, b, x)

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

if n < b:
  for x in range(n + 1):
    ans = f1(a, b, x)
    if ans > result:
      result = ans
else:
  for x in range(b, n + 1):
    ans = f1(a, b, x)-f2(a, b, x)
    if ans > result:
      result = ans

print(result)

Submission status: Wrong Answer

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

def function(x, a=a, b=b):
    return int(a * x / b) - a * int(x / b)

ans = function(1)
for i in (1, n):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(n * b - 1))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
# ~n,m,q  = map(int,input().split())

# ~seq = [-1]*n;

# ~qs = []
# ~for i in range(q):
	# ~a,b,c,d = map(int,input().split())
	# ~qs.append([a,b,c,d])
# ~qs = sorted(qs, key = lambda x :x[3], reverse = True)


# ~ans = 0

# ~for i in range(q):
	# ~if (seq[qs[i][0]-1] == -1 and seq[qs[i][1]-1] == -1):
		# ~seq[qs[i][1]-1] = qs[i][2]
		# ~seq[qs[i][0]-1] = 1
		# ~ans += qs[i][3]
	# ~else:
		# ~if (seq[qs[i][1]-1] - seq[qs[i][0]-1] == qs[i][2]):
			# ~ans += qs[i][3]
# ~print(ans)

	
	
# ~floor(Ax/B)−A×floor(x/B)

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

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

# ~x = math.ceil((1+2*b)/a)
# ~print(x)


# ~print(f(a,b,x))

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

print(ans)

Submission status: Wrong Answer

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

def main():
    a, b, n = map(int, input().split())
    x = min(n + 1, b - 1)
    X = (a * x) // b
    Y = a * (x // b)
    print(X - Y)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = min(n, b)


mem = {}
m = 0


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

Submission status: Wrong Answer

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


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

left = 1
right = N

while right - left > 1:
    mid = (left + right) // 2
    y = target(mid)
    prv = target(mid - 1)
    nxt = target(mid + 1)
    if prv <= y <= nxt:
        left = mid
    else:
        right = mid

if right + 1 <= N and target(right + 1) > target(right):
    print(target(right + 1))
elif right - 1 >= 1 and target(right - 1) > target(right):
    print(target(right - 1))
else:
    print(target(right))

Submission status: Wrong Answer

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

nibu_max = n
nibu_min = 1
nibu_mid = (1 + n) // 2


for i in range(int(math.log(n, 2)) + 1):
    sss_max = int(a * nibu_max / b) - a * int(nibu_max / b)
    sss_mid = int(a * nibu_mid / b) - a * int(nibu_mid / b)
    sss_min = int(a * nibu_min / b) - a * int(nibu_min / b)

    if sss_max > sss_mid:
        nibu_min = nibu_mid
        nibu_mid = 1 + int((nibu_max + nibu_min) / 2)
    elif sss_mid < sss_min:
        nibu_max = nibu_mid
        nibu_mid = int((nibu_max + nibu_min) / 2) - 1
    else:
        print(int(a * nibu_mid / b) - a * int(nibu_mid / b))
        sys.exit()
print(int(a * nibu_mid / b) - a * int(nibu_mid / b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect

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

def solve(a, b, n):
    left = 1
    right = n
    while right - left >= 3:
        m1 = left + (right - left) // 3
        m2 = left + (right - left) // 3 * 2
        val1 = query_value(a, b, m1)
        val2 = query_value(a, b, m2)
        if val1 >= val2:
            right = m2
        else:
            left = m1
    max_val = query_value(a, b, left)
    for i in range(left, right + 1):
        val = query_value(a, b, i)
        max_val = max(max_val, val)
    return max_val

def main():
    a, b, n = map(int, input().split())
    print(solve(a, b, n))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(li)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
for i in range(n,-1,-1):
    ans = ((a*i)//b)-(a*(i//b))
    al.append(ans)
    if len(al) > 1:
        if al[-1] <= al[-2]:
            break
if max(al) < 0:
    print(0)
else:
    print(max(al))

Submission status: Wrong Answer

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

k = gcd(A, B)

As = A // k
Bs = B // k

if B < 100:
    res = []
    for n in range(min(N+1, B+1)):
        res.append(floor(As*n/Bs)-As*floor(n/Bs))
    
    print(max(res))
    exit()

if Bs-1 <= N:
    m = Bs - 1
else:
    m = N
print(floor(As * m / Bs) - As * floor(m / Bs))
# for x in range(1, N+1):
#     print(floor(As*x/Bs)-As*floor(x/Bs))

Submission status: Wrong Answer

Solution code:
import math

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

# 入力を取得
(a, b, n) = list(map(int, input().split(' ')))

# 計算結果を貯めるlist

# 最大値格納
max = 0

for i in range(1, n + 1):
  ret = get_calc(a, b, i)
  if (ret > max):
    max = ret
  
print(ret)

Submission status: Wrong Answer

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

ans = 0
count = 0
for x in range(N,0,-1):
    if count > 1000000:
        break
    xb = x / B
    if xb < 1 and ans != 0:
        count += 1        
#         print("continue")
        continue
    floor = int(A*xb) - A * int(xb)
    if ans < floor:
        count = 0
        ans = floor
    count += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A,B,N=map(int,input().split())
if A==B:
  if N<A:
    print(N)
  else:
    print(A-1)
elif A<B:
  if N<B:
    print(int(A*N/B)-A*int(N/B))
  else:
    print(int(A*(B-1)/B))
else:
  if N<B:
    print(int(A*N/B)-A*int(N/B))
  else:
    num0=int(A*N/B)-A*int(N/B)
    N2=N-(N%B)-1
    num1=int(A*N2/B)-A*int(N2/B)
    print(max(num0,num1))

Submission status: Wrong Answer

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

if a <= 1:
    n = 0

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
line = list(map(int,input().split()))

A,B,N =line[0],line[1],line[2]

ans = (N+1)//B
kouho =[0 for j in range(ans)]
for i in range(1,ans+1):
    x= i*B-1
    kouho[i-1]=(math.floor(A*x/B)-A*math.floor(x/B))

kouho.append(math.floor(A*N/B)-A*math.floor(N/B))
print(min(kouho))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0

for x in range(1, A[2]+1):
  if i_max < ((A[0]*x)//A[1]-A[0]*(x//A[1])):
    i_max = (A[0]*x//A[1]-A[0]*(x//A[1]))
    i_count = x
  if (x - i_count) == 1:
    j_count = j_count + 1
  if (j_count == 2):
    break
    
print(i_count)

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  # right=n
  # ans=math.floor(a*right/b)-a*math.floor(right/b)
  # left=0
  # while left<=right:
  #   half=(left+right)//2
  #   _ans=math.floor(a*half/b)-a*math.floor(half/b)
  #   if _ans==ans:
  #     return ans
  #   elif _ans>ans:
  #     right=half-1
  #     ans=_ans
  #   else:
  #     left=half+1

  ans=int(a*1/b)-a*int(1/b)
  x=int(math.sqrt(n))
  for i in range(max(0,n-x-2),n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
arr = input().split(' ')
a = int(arr[0])
b = int(arr[1])
n = int(arr[2])

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

Submission status: Wrong Answer

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

max_num = -1
for x in range(n+1):
  tmp = a * x / b // 1 - a * (x / b // 1)
  if max_num < tmp:
    max_num = tmp
  else:
    print(int(max_num))
    break

Submission status: Wrong Answer

Solution code:
import math

a,b,n = map(int,input().split())
ma = -1*(10**13) 

for i in range(1,b+1):
    if b % i == 0:
        continue
    c = math.floor(i/b)
    tmp = math.floor((a*i)/b)-(a*c)
    if ma < tmp:
        ma = tmp

print(ma)

Submission status: Wrong Answer

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

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

high = N
low = 0
while high - low > 1:
    mid_left = high / 3 + low * 2 / 3
    mid_right = high * 2 / 3 + low / 3
    # print(mid_left, mid_right)
    if f(mid_left) > f(mid_right):
        high = mid_right
    else:
        low = mid_left
print(f(high))

Submission status: Wrong Answer

Solution code:
import math

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

l = [0]

for x in reversed(range(0,n+1)):
    ans = 0
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    l.append(ans)
    if max(l) > ans:
        break
#print(l)
print(max(l))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, n = [int(i) for i in input().split()]

if n >= b+((b-a)/a):
  ans = (a*(b-1+((b-a)/a)))//b - a*((b-1+((b-a)/a))//b)
  print(ans)
  quit()

ans = (a*n)//b - a*(n//b)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt=0
if b>10**9:
	for i in range(1000000000):
		cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	print(cnt)

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

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def factorization(n):
	tmp=n
	count=0
	for i in range(2,int(n**0.5)+2):
		if tmp%i==0:
			cnt=0
			while tmp%i==0:
				cnt+=1
				tmp//=i
			count+=1
	if tmp!=1:
		count+=1

	return count
			

def fl(a,b,x):
	x=math.floor(a*x/b)
	y=a*math.floor(x/b)
	


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

a,b,n=input2()
if b>n:
	b_ans=fl(a,b,n)
else:
	b_ans=fl(a,b,b-1)

# for i in range(0,n,b):
# 	ans=fl(a,b,i)
# 	if ans> b_ans:
# 		b_ans=ans
# if i<n:
# 	ans=fl(a,b,n)
# 	if ans> b_ans:
# 		b_ans=ans
print(b_ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
bll=[]
for j in range(1,10**12):
  bl=b*j-1 
  bll.append(bl)
  if b*j-1>10*12:
    break
ans=0
if n<b:
  ans=math.floor(a*n/b)
else:
  for i in range(bl):
    ans=max(ans,math.floor(a*i/b)-a*math.floor(i/b))
print(ans)

Submission status: Wrong Answer

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

x = list()
if n<=b:
  for i in range(n+1):
    y = int(a*(i+1)/b) - a*int((i+1)/b)
    x.insert(bisect.bisect_left(x,y),y)
else:
  for i in range(b):
    y = int(a*(i+1)/b) - a*int((i+1)/b)
    x.insert(bisect.bisect_left(x,y),y)

print(x[-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a<= 2 and  b <= 2:
    print(0)
elif a <= b and n >=b:
    print(a-1)
elif a<= b and n < b:
    print(f(n))
elif a>b and n >= b:
    print(a-2)
elif a>b and n < b:
    print(f(n))

Submission status: Wrong Answer

Solution code:
import math

#数値ひとつ
#I = int(input())
#数値空白区切りで欲しいとき
A, B, N = map(int, input().split())
#文字欲しいとき
#N = input()
#それをListにしたいとき
#list = list(N)
#数値を受け取る数が未定かつリストにしたいとき
#list = list(map(int, input().split()))
#受け取る文字列が未定かつリストにしたいとき(Iは回数)
#list = [input() for i in range(I)]
list = []

if N >= 1000000:
    for i in range(N-1000000,N+1):
        list.append(0)
else:
    for i in range(N+1):
        list.append(math.floor(A*i/B)-A*math.floor(i/B))

print(max(list))

Submission status: Wrong Answer

Solution code:
# ABC165c
last = 0


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)
    from math import floor
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

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

    def evaluate(number):
        return floor(a*number/b)-a*floor(number/b)
        if number < 100:  # もっと高い値を探せ
            return 1
        if number == 100:  # まさにこの値
            return 0
        if number > 100:  # もっと低い値を探せ
            return - 1

    def binary_search(low, high):
        global last
        lowest = low
        highest = high
        while low < high:  # high-low >= 10**-12 ←これ以下の誤差を許容
            mid = (low + high) // 2
            left = (low + mid) // 2
            right = (mid+high)//2
            lv = evaluate(left)
            rv = evaluate(right)
            mv = evaluate(mid)
            #print(low, high)
            if lv < rv:
                last = max(mv, rv)
                low = mid
                lowest = mid
            else:
                last = max(mv, lv)
                high = mid
                highest = mid
            continue

            if guess == 0:
                return [mid, mid]
            if guess < 0:
                high = mid - 1  # 連続値の場合mid
                highest = mid
            else:
                low = mid + 1  # 連続値の場合mid
                lowest = mid

        return [lowest, highest]

    t = binary_search(0, n + 1)[0]
    #print(t, last)
    print(max(evaluate(t-2), evaluate(t-1), evaluate(max(n, t)),
              evaluate(max(n, t+1)), evaluate(max(n, t+2)), last))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
# ~n,m,q  = map(int,input().split())

# ~seq = [-1]*n;

# ~qs = []
# ~for i in range(q):
	# ~a,b,c,d = map(int,input().split())
	# ~qs.append([a,b,c,d])
# ~qs = sorted(qs, key = lambda x :x[3], reverse = True)


# ~ans = 0

# ~for i in range(q):
	# ~if (seq[qs[i][0]-1] == -1 and seq[qs[i][1]-1] == -1):
		# ~seq[qs[i][1]-1] = qs[i][2]
		# ~seq[qs[i][0]-1] = 1
		# ~ans += qs[i][3]
	# ~else:
		# ~if (seq[qs[i][1]-1] - seq[qs[i][0]-1] == qs[i][2]):
			# ~ans += qs[i][3]
# ~print(ans)

	
	
# ~floor(Ax/B)−A×floor(x/B)

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

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

# ~x = math.ceil((1+2*b)/a)
# ~print(x)


# ~print(f(a,b,x))

ans = math.floor(n/(b/a))
if ans > n:
	ans = 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)
syou = n/b
Max = max(f(syou),f(n))
print(Max)

Submission status: Wrong Answer

Solution code:
import math

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


# A,B,N = 99,15,117
# A,B,N = 5,7,4
# A,B,N = 11,10,9

# 答えが最大になるｘの位置
if N > B:
    ans_x = (N // B) * B - 1
else:
    ans_x = N

l = math.floor((A * ans_x) / B)
r = A * math.floor(ans_x / B)

print(l - r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
a,b,n = map(int,input().split())
ans = 0
al = []
al2 = 0
for i in range(n,-1,-1):
    ans = ((a*i)//b)-(a*(i//b))
    al.append(ans)
    if al2 < ((a*i)/b)-(a*(i/b)):
        break
    al2 = ((a*i)/b)-(a*(i/b))
    
if max(al) < 0:
    print(0)
else:
    print(max(al))

Submission status: Wrong Answer

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

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

c = (n//b)*b-1
temp1 = math.floor(a*c/b) - a*math.floor(c/b)#一番大きい倍数の前
temp2 = math.floor(a*n/b) - a*math.floor(n/b)#とれる最大のｎ

print(max(temp1,temp2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
c = 0
t = -10
if N > 100000000:
    for i in range(100000000, N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 200000000:
            print(c)
            break
        t = a
    else:
        print(c)
else:
    for i in range(N + 1):
        a = (i * A) // B - A * (i // B)
        c = max(c, a)
        if t > a or i > 100000000:
            print(c)
            break
        t = a
    else:
        print(c)

Submission status: Wrong Answer

Solution code:
import math

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

left, right = 0, n
while right > left + 10:
    mid1 = (right * 2 + left) // 3
    mid2 = (right + left * 2) // 3
    if f(mid1) <= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid2
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid1
listalt = []
for i in range(int(left), int(right) + 1):
    listalt.append(f(i))
listalt.append(f(0))
listalt.append(f(n))
print(max(listalt))

Submission status: Wrong Answer

Solution code:
import math

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

l = [0]

for x in reversed(range(0,n+1)):
    ans = 0
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    l.append(ans)
    if max(l) > ans:
        break
print(l)
print(max(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  # right=n
  # ans=math.floor(a*right/b)-a*math.floor(right/b)
  # left=0
  # while left<=right:
  #   half=(left+right)//2
  #   _ans=math.floor(a*half/b)-a*math.floor(half/b)
  #   if _ans==ans:
  #     return ans
  #   elif _ans>ans:
  #     right=half-1
  #     ans=_ans
  #   else:
  #     left=half+1

  ans=int(a*1/b)-a*int(1/b)
  x=int(math.sqrt(n))
  for i in range(n-x-1,n+1):
    ans=max(ans,int(a*i//b)-a*int(i//b))
  return ans

# main()
print(main())

Submission status: Wrong Answer

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

res = (A*(N))//B - (A*((N)//B))
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import gcd
A,B,N = list(map(int,input().split()))
ans = 0
lcm = A*B//gcd(A,B)
if N < 2*10**6:
    if lcm <= N:
        ans = max(ans,(A*lcm//B)-A*(lcm//B))
        tmp = (N//lcm)*lcm
        ans = max(ans,(A*tmp//B)-A*(tmp//B))
    for x in range(N+1):
        ans = max(ans,(A*x//B)-A*(x//B))
else:
    for x in range(10**6+2):
        ans = max(ans,(A*x//B)-A*(x//B))
    for x in range(N,N-10**6,-1):
        ans = max(ans,(A*x//B)-A*(x//B))
    if lcm <= N:
        ans = max(ans,(A*lcm//B)-A*(lcm//B))
        tmp = (N//lcm)*lcm
        ans = max(ans,(A*tmp//B)-A*(tmp//B))
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,n=list(map(int,input().split()))
y=0
for x in range(n+1):
    y_i=x%b
    if y_i>y:
        y=y_i
z=(a*y_i)//b
print(z)

Submission status: Wrong Answer

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

ans = 0
#for x in range(1, N+1):
#    total = ((A * x) // B) - A * (x // B)
#    print(x, total)
#print(ans)

if len(str(B)) == 1:
    print(((A * (N-1)) // B) - A * ((N-1) // B))
else:
    print(((A * N) // B) - A * (N // B))

Submission status: Wrong Answer

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

tmp = (N//B)*B + (N%B)
if N%B == 0:
    print(int(A*(tmp-1)/B - A*int((tmp-1)/B)))
else:
    print(int(A*(tmp)/B - A*int((tmp)/B)))

Submission status: Wrong Answer

Solution code:
def main():
  import math
  A, B, N = map(int, input().split())
  p = 0
  tobi = B / A
  for i in reversed(range(int(N / tobi))):
    x = math.ceil(tobi * (i+1))
    score = ((A * x) // B) -  (A *(x // B))
    if score > p:
      p = score
    elif score < p:
      break
      
  print(p)

main()

Submission status: Wrong Answer

Solution code:
import math

if __name__ == '__main__':
    a, b, n = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
A, B, N = [int(i) for i in input().split()]
if B == 1:
    max = 0
elif B >= N:
    x = N
    max = ((A * x) // B) - A * (x // B)
else:
    if (B * ((N // B) + 1) - 1) <= N:
        x = B * (N // B + 1) - 1
    else:
        x = B * (N // B) - 1
    max = ((A * x) // B) - A * (x // B)
print(max)

Submission status: Wrong Answer

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

cnt=0
if b>10**9:
	for i in range(1000000):
		cnt=max(cnt,(a*(n-i)//b-a*((n-i)//b)))
	print(cnt)

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