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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

from decimal import *

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 累乗 #####
# pow(x, y, z) -> x**y % z

##### 割り算の切り上げ #####
# tmp = -(-4 // 3)

##### dict の for文 #####
# for k, v in d.items():
#     print(k, v)

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	A,B,N = inputMap()

	maxs = 0
	conts = 10000
	for x in range(N,0,-1):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	conts = 12000000
	for x in range(N//2-1,N):
		tmp = math.floor(A * x / B) - A * math.floor(x / B)
		conts -= 1
		if maxs < tmp:
			maxs = tmp
		if conts == 0:
			break

	print(maxs)



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# mを法とするaの乗法的逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

# nHr mod m
# 問題によって、combination()を切り替えること
def H(n, r, mod=10**9+7):
	# comb = Combination(n+r-1, mod)
	# return comb(n+r-1, r)
    return combination(n+r-1, r, mod)


class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
# dfs のサンプル
def dfs(graph,parent,counter,edge):
    stk = []
    stk.append(edge)
    while len(stk) > 0:
        p = stk.pop()
        for e in graph[p]:
            if parent[p] == e:
                continue
            else:
                parent[e] = p
                counter[e] += counter[p]
                stk.append(e)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

y = int(a*bdash/b)-a*int(bdash/b)
z = int(a * (a - 1) / b) - a * int((a - 1) / b)

print(max(z,y,x))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
inp=[int(x) for x in input().split()]
a,b,n=inp[0],inp[1],inp[2]
arr=[math.floor(a*i/b)-a*math.floor(i/b) for i in range(1000000)]
new=[]
for x in arr:
  if x<=n:
    new.append(x)
print(max(new))

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        if c >= m:
            m=c
        else:
            break
print(m)

Submission status: Wrong Answer

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

Ansermax = 0

if b < N :
    N = b
    
for x in range(N+1):
  while x//b >= 1:

    Anser = 0

    Anser = int((a*x)//b)-a*int(x//b)
    
    if Ansermax < Anser:
        Ansermax = Anser

print(Ansermax)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B, N = map(int, input().split())
dic = {}
if N <= 10**6:
    for i in range(1, N+1):
        tmp = floor(A*i/B) - A*floor(i/B)
        if tmp in dic:
            dic[tmp] += 1
        else:
            dic[tmp] = 1
else:
    for i in range(1, 10**6+1):
        tmp = floor(A*i/B) - A*floor(i/B)
        if tmp in dic:
            dic[tmp] += 1
        else:
            dic[tmp] = 1
ans = -1
for k, v in dic.items():
    ans = max(ans, k)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,n = inpm()
    print(max(int(a*(b-1)/b),int(a*n/b)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if n <= b:
    print(calc(n))
else:
    print(calc(b-(a/(2*b))))

Submission status: Wrong Answer

Solution code:
A, B, N = map(int, input().split())
Max = 0
 
floor = int(A*N/B) - A*int(N/B)

if floor < 0:
  floor = 0
    
print(floor)

Submission status: Wrong Answer

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

tmp = 0
a = 0
i = 0
past = 0

for i in range(N - N % B - 1, -1, -B):
    if (s := (A * i) // B - A * (a)) > past:
        past = s
        tmp = max(s, tmp)
    else:
        break

if i >= N - B:
    for i in range(N, N - N % B - 1, -1):
        if (s := (A * i) // B - A * (i // B)) > 0:
            tmp = max(s, tmp)
        else:
            break

print(tmp)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int,input().split())
max=0
pre=0
if b//a==0:
    st=1
else:
    st=b//a
check=0
for i in range(0,n+1,st):
    f=math.floor(a*i/b)-a*math.floor(i/b)
    if f>=max:
        max=f
    if f==0:
        check+=1
    if check>st:
        break

print(max)

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(int(n), 0, -2):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Wrong Answer

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

max=0
if N>B:
  N=B
  y=math.floor(A*N/B)-A*math.floor(N/B)
  print(int(y))
elif N==B:
  N=B-1
  y=math.floor(A*N/B)-A*math.floor(N/B)
  print(int(y))
else:
	for i in reversed(range(1, N+1)):
		y=math.floor(A*i/B)-A*math.floor(i/B)
		if max < y :
			max=y
	print(int(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):
    t = (a*i)//b
    t2 = a*(i//b)
    ans = t-t2
    al.append(ans)
    if len(al) > 2:
        if al[-1] <= al[-3]:
            break
for i in range(0,n+1):
    t = (a*i)//b
    t2 = a*(i//b)
    ans = t-t2
    al.append(ans)
    if len(al) > 2:
        if al[-1] <= al[-3]:
            break
            
if max(al) < 0:
    print(0)
else:
    print(max(al))

Submission status: Wrong Answer

Solution code:
import math
def fs(A, B, x):
    return math.floor(A*x/B) - A * math.floor(x/B)


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

    low = 1
    high = N

    ans = fs(A, B, low)

    while abs(low - high) != 1:
        #print(low, high)
        mid = (high + low) // 2
        tmp = fs(A, B, mid)
        if tmp > ans:
            ans = tmp
            low = mid
        else:
            high = mid

    #print(low, high)
    print(max(fs(A, B, low), fs(A, B, high)))
    return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A,B,N= list(map(int, input().split()))
ma=0
for i in range(1,min(N,B)+1):
    a=int(A*i/B)-A*int(i/B)
    print(a)
    if(ma<a):
        ma=a
    if(a>=A):
      break
print(ma)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import math

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

  ans = 0
  for i in [N, N-1]:
    tmp = math.floor((A*i)/B)-(A*(math.floor(i/B)))
    ans = max(ans, tmp)
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

z = 0

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

print("{}".format(z))

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
import math

a, b, n = map(int, input().split())
li = []
x = math.floor(n)
an = math.floor(a*x//b) - a * math.floor(x//b)
li.append(an)
print(max(li))

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
i_max = 0
i_count = 0
j_count = 0
h_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 (i_count != 0) and (i_count != x):
    break
    
print(i_count)

Submission status: Wrong Answer

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

    A_ans = 0
    for i in range(min(N, B), 1, -2):
        tmp = (A * i // B) - A * (i // B)
        A_ans = max(tmp, A_ans)

    print(A_ans)


resolve()

Submission status: Wrong Answer

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=0.1, max_loop=100):
    #初期値を表示
    num_calc = 0  #計算回数
    #print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    #    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        #print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        #   quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = (x_max +x_min)/2.0
        
        x_mid_max = (x_max +x_mid)/2.0
        x_mid_mim = (x_min +x_mid)/2.0
        
        #探索区間を更新
        if func_f(A,B,x_max) < func_f(A,B,x_mid):
            x_min = x_mid
        elif func_f(A,B,x_min) < func_f(A,B,x_mid):
            x_max = x_mid
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
#print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    solution = bisection(func_f, 0, N,A,B)
    print(-func_f(A,B,solution))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys

A, B, N = [int(x) for x in stdin.readline().rstrip().split()]
# N, M = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
ans = int((A*N)/B)-A*int(N/B)
if N >= B:
    n = N//B
    n = n*B
    ans1 = int((A*(n-1))/B)-A*int((n-1)/B)
    ans3 = int((A*(n+1))/B)-A*int((n+1)/B)
    ans2 = int((A*(B-1))/B)-A*int((B-1)/B)
    ans4 = int((A*(B+1))/B)-A*int((B+1)/B)
else:
    ans1 = ans
    ans2 = ans
    ans3 = ans
    ans4 = ans
# if N > 100000:
#     p = N-100000
# else:
#     p = 1
# for i in range(p, N+1):
#     temp = int((A*i)/B)-A*int(i/B)
#     if temp > ans:
#         # print(i)
#         ans = temp

print(max(ans, ans1, ans2, ans3, ans4))

Submission status: Wrong Answer

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

if b >= n:
    x = n
else:
    x = b - 1

max_num = a * x // b - (a * (x // b))
print(max_num)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math
A, B, N = map(int, input().split())
t = N // B
if N % B == 0:
    a = max(0, N-1)
    b = N
    d = max(0,t*B-1)
    e = 1
    f = 0
else:
    a = max(0, t * B - 1)
    b = N
    d = max(0,N-1)
    e = 1
    f = 0

k = A * N // B
if A * N % B == 0:
    case = [a, b, max(min(B-1,N),0),d,e,f]
else:
    c = max(1,k*B//A+1)
    case = [a,b,c,max(min(B-1,N),0),d,e,f]

ans = 0
for i in case:
    ans = max(ans,math.floor(A*i/B)-A*(math.floor(i/B)))

print(ans)

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B, N = map(int,input().split())
ans = -100000000000
pre = 10**9
ans = 0

for i in range(min(A,B,N)):
    t = (A*i) // B - A * (i//B)
    if pre < ans :
        break
    if ans < t:
        ans = t
    pre = t
print(ans)




#for i in range(N):
#    t = (A*i) // B - A * (i//B)
#    print(i, t,(A*i) // B, A * (i//B))
#    if ans < t :
#        ans = t
#print(ans)

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(round(floor(As*n/Bs)-A*floor(n/B)))
# 
#     print(max(res))
#     exit()

if B-1 <= N:
    m = B - 1
elif Bs - 1 <= N:
    m = Bs - 1
else:
    m = N
print(round(floor(As * m / Bs) - As * floor(m / Bs)))

Submission status: Wrong Answer

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import math
A,B,N = map(int,input().split())
#left = math.floor(A/B)
if A>=B:
    print(math.floor((A*N)/B)-A*math.floor(N/B))
else:
    N = N-1
    print(math.floor((A*N)/B)-A*math.floor(N/B))

Submission status: Wrong Answer

Solution code:
a,b,n = map(int,input().split())
x = 0
loop1 = n//b + 2
if loop1 > 10**5:
    loop1 = 10**5
    
loop2 = n//a + 2
if loop2 > 10**5:
    loop2 = 10**5

max_ = 0
    
if n < 10**6:
    for x in range(1, n + 1):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

else:
    for x in range(1, 10**6):
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp
            
    for i in range(1, loop1):
        x = i*b - 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        if tmp > max_:
            max_ = tmp

    for i in range(1,loop2):
        x = i*a + 1
        if x > n:
            continue
        tmp = (a*x)//b - a*(x//b)
        print((a*x)//b,a*(x//b), tmp)
        if tmp > max_:
            max_ = tmp
    
print(max_)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from math import floor
import random

A, B, N = map(int, input().split())
ans = -1
for _ in range(10000):
    n = random.randrange(N+1)
    m = floor(Fraction(A * n, B)) - A * floor(Fraction(n, B))
    if m > ans:
        ans = m

print(ans)

Submission status: Wrong Answer

Solution code:
def calc(A, B, N):
    return max(map(lambda x: int(A * x / B) - A * int(x / B), range(N - 10000, N + 1)))


def main():
    A, B, X = list(map(int, input().split(' ')))
    print(calc(A, B, X))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

ans = 0

#bがnよりも大きい時
if b > n:
    ans = int(a*n/b)
    print(ans)
    exit()

#b==nのときは、終了間際の2個だけ比較する
elif b == n:
    for i in range(n-1,n+1):
        tmpans = int(a*i/b) - (a*int(i/b))
        if tmpans >= ans:
            ans = tmpans
    print(ans)
    exit()

#これ以外の時は、nはb値ごとにスキップする。
else:
    for i in range(1,n+1,a*b):
        tmpans = int(a*(i-2)/b) - (a*int((i-2)/b))
        if tmpans >= ans:
            ans = tmpans

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
a,b,n = map(int, input().split())

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

ma = num(1)

for i in range(2, n+1):
    if num(i) > ma:
        ma = num(i)
    else:
        print(ma)
        exit()
print(ma)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)
a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    if k==1:
        ret = max(f(a,b-1,b), f(a,n,b))
    else:
        x = b*k-1
        ret = f(a,x,b)
    print(ret)

Submission status: Wrong Answer

Solution code:
import math
a,b,n=map(int, input().split()) 
max = -10000
tmp = 0

for i in range(1, n + 1):
    tmp = math.floor(a * i / b) - math.floor(i / b)
    if max < tmp:
        max = tmp
    else:
        break

print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def obj_f(x):
    res = int(a*x/b) - a*int(x/b)
    return(res)

x = 1

ima = obj_f(1)
migi = obj_f(2)

while ima < migi and x <= n:
    x = int(2*x)
    ima = obj_f(x)
    migi = obj_f(int(2*x))

prev_x = int(0.5*x)
next_x = min(int(2*x), n)

while True:
    if obj_f(((x + next_x)/2)) >= obj_f(((x + prev_x)/2)):
        prev_x = x
        x = ((x + next_x)/2)
    else:
        next_x = x
        x = ((x + prev_x)/2)
    if x - prev_x < 1 and next_x - x < 1:
        break

import math
print(max([obj_f(math.floor(x)), obj_f(math.ceil(x))]))

Submission status: Wrong Answer

Solution code:
def main():
  import math
  A, B, N = map(int, input().split())
  p = 0
  tobi = B / A
  
  y_0 = math.ceil(tobi * ((int(N / tobi) //2 )+1))
  y_1 = math.ceil(tobi * ((int(N / tobi) //2 )+2))
  y_2 = math.ceil(tobi * ((int(N / tobi) //2 )+3))
  start_0 = ((A * y_0) // B) -  (A *(y_0 // B))
  start_1 = ((A * y_1) // B) -  (A *(y_1 // B))
  start_2 = ((A * y_2) // B) -  (A *(y_1 // B))
  
  if start_2 > start_1: 
    for i in range(int(N / tobi) //2 ,int(N / tobi)):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score

  else:
    for i in range(0 ,int(N / tobi) //2, -1):
      x = math.ceil(tobi * (i+1))
      score = ((A * x) // B) -  (A *(x // B))
      if score > p:
        p = score
     
  print(p)
 
main()

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
a,b,c=[int(_) for _ in input().split()]
k=c-1
s=math.floor((k*a)/b)-a*math.floor(k/b)
t=math.floor((c*a)/b)-a*math.floor(c/b)
if b<c:
    l=b-1
    g=b
    v=math.floor((l*a)/b)-a*math.floor(l/b)
    m=math.floor((g*a)/b)-a*math.floor(g/b)
    print(s,t,m,v)
else:
    print(max(s,t))

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(10**9)

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

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

    def bin(a):
        left = 0
        right = A+1

        while right-left > 1:
            x = (right+left) // 2
            # print(left,right)
            if f(x) < a:
                left = x
            else:
                right = x

        # print("____")
        # print(right)
        return right


    for _a in range(A+1):
        a = A - _a
        x = bin(a)
        # print(x,a)
        if 0<=x<=N and f(x) == a:
            print(a)
            exit()


if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

    if  math.floor((x*A)/B)-A*(math.floor(x/B))<=kioku:
        break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    return max

if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

A, B , N=  [int(i) for i in input().split()]

#if A > B:

N  = int(int(A*N/B) * B /A)+1
print(int(A*N/B) - A*int(N/B))

#else:

Submission status: Wrong Answer

Solution code:
# abc165_d.py
A, B, N = map(int,input().split())
ans = -100000000000
pre = 10**9
ans = 0

for i in range(min(A,B,N+1)+100):
    t = (A*i) // B - A * (i//B)
    if pre < ans :
        break
    if ans < t:
        ans = t
    pre = t
print(ans)




#for i in range(N):
#    t = (A*i) // B - A * (i//B)
#    print(i, t,(A*i) // B, A * (i//B))
#    if ans < t :
#        ans = t
#print(ans)

Submission status: Wrong Answer

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

x = 0
now = 0
result = 0

    

for i in range((b//2)-1,n+1):
    if x > b:
        break
    x = i
    now = (((a * x)//b)) - (a * (x//b))
    #now = math.ceil(((a * x)/b)) - (a * math.ceil(x/b))
    #print("now=",now,"x=",x)
    #print(result,now)
    result = max(result,now)

print(result)

Submission status: Wrong Answer

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


def calculate(a, b, n):
    s1 =  a * n // b
    if N > b:
        if n >= 2 * b:
            x = b + b - 1
        else:
            x = n
        return max(s1,(a * x) // b + a * (x // b))

    return s1


print(calculate(A, B, N))

Submission status: Wrong Answer

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

ans = 0

if b == 1:
  ans = 0

else:
  for x in range(0, a * n, b):
    new = math.floor(x / b) - a * math.floor(math.floor(x / a) / b)
    if new > ans:
      ans = new

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

m = 0
c = 0
if n<b:
    m = math.floor(a*n/b)
else:
    m = a
    for x in range(b,n+1,b):
        c = math.floor(a*x/b)-a*math.floor(x/b)
        if c >= m:
            m=c
        else:
            break
print(m)

Submission status: Wrong Answer

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

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

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

ans = max(buf)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
A, B , N = map(int, input().split())
List = []
for x in range(N-4,N+1):
    Answer = abs(floor((A*x)/B) - (A*floor(x/B)))
    List.append(Answer)

print(max(List))

Submission status: Wrong Answer

Solution code:
#二分法による非線型方程式の解法プログラム
import numpy as np  #数値計算用モジュール

#解きたい方程式
def func_f(A,B,x):
    return -(int(A*x/B)-A*int(x/B))


#二分法（方程式の関数項、探索区間の左端、探索区間の右端、誤差範囲、最大反復回数）
def bisection(func_f, x_min, x_max, A, B, error=1, max_loop=100):
    #初期値を表示
    num_calc = 0  #計算回数
    #print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
    
    #中間値の定理の条件を満たすか調べる
    #    if(0.0 < func_f(A,B,x_min)*func_f(A,B,x_max)):
        #print("error: Section definition is invalid (0.0 < func_f(x_min)*func_f(x_max)).")
        #   quit()

    #ずっと繰り返す
    while(True):
        #新たな中間値の計算
        x_mid = (x_max +x_min)/2.0
        
        x_mid_max = (x_max +x_mid)/2.0
        x_mid_mim = (x_min +x_mid)/2.0
        
        #探索区間を更新
        if func_f(A,B,x_max) < func_f(A,B,x_mid):
            x_min = x_mid
        elif func_f(A,B,x_min) < func_f(A,B,x_mid):
            x_max = x_mid
        elif func_f(A,B,x_mid_max) < func_f(A,B,x_mid_mim):  #中間と右端の値が同じの時
            x_max = x_mid  #右端を更新
        else:  #中間と左端の値が同じの時
            x_min = x_mid  #左端を更新
        
        #結果を表示
        num_calc += 1  #計算回数を数える
#print("{:3d}:  {:.15f} <= x <= {:.15f}".format(num_calc, x_min, x_max))
        
        #「誤差範囲が一定値以下」または「計算回数が一定値以上」ならば終了
        if((x_max-x_min <= error) or max_loop <= num_calc):
            break

    #最終的に得られた解
    #print("x = {:.15f}".format(x_mid))

    return x_mid


#メイン実行部
if (__name__ == '__main__'):
    A,B,N=(int(x) for x in input().split())
    #二分法で非線型方程式の解を計算
    solution = bisection(func_f, 0, N,A,B)
    print(-func_f(A,B,solution))

Submission status: Wrong Answer

Solution code:
import math

A, B, N = (int(x) for x in input().split())
h = []
a = 0
c = 0
for i in range(0, N+1):
    a = math.floor(A * i / B) - A * math.floor(i / B)
    if a > c:
        c = a
print(a)

Submission status: Wrong Answer

Solution code:
import math

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

for x in range(int(n), int(n-100), -1):
    n = math.floor(a*x/b) - a * math.floor(x/b)
    if ans <= n:
      ans = n
  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[0][1]
n = listA[0][2]

old = 0
for x in range(1,n):
  if x == 1:
    old = math.floor(a*x/b)-a*math.floor(x/b)
  else:
    current = math.floor(a*x/b)-a*math.floor(x/b)
    if old < current:
      old = current
    
print (old)

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, max(1, (n + 1) // b)):
    if i * b - 1 > n:
        ans = max(ans, function(n))
        break
    ans = max(ans, function(i * b - 1))

print(max(ans, function(n)))