結果

問題 No.176 2種類の切手
ユーザー convexineqconvexineq
提出日時 2020-12-15 20:53:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 1,000 ms
コード長 600 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 53,516 KB
最終ジャッジ日時 2023-10-20 06:34:44
合計ジャッジ時間 2,926 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,516 KB
testcase_01 AC 42 ms
53,516 KB
testcase_02 AC 41 ms
53,516 KB
testcase_03 AC 41 ms
53,516 KB
testcase_04 AC 40 ms
53,516 KB
testcase_05 AC 42 ms
53,516 KB
testcase_06 AC 44 ms
53,516 KB
testcase_07 AC 41 ms
53,516 KB
testcase_08 AC 41 ms
53,516 KB
testcase_09 AC 40 ms
53,516 KB
testcase_10 AC 39 ms
53,516 KB
testcase_11 AC 41 ms
53,516 KB
testcase_12 AC 39 ms
53,516 KB
testcase_13 AC 40 ms
53,516 KB
testcase_14 AC 39 ms
53,516 KB
testcase_15 AC 41 ms
53,516 KB
testcase_16 AC 40 ms
53,516 KB
testcase_17 AC 41 ms
53,516 KB
testcase_18 AC 41 ms
53,516 KB
testcase_19 AC 41 ms
53,516 KB
testcase_20 AC 43 ms
53,516 KB
testcase_21 AC 43 ms
53,516 KB
testcase_22 AC 40 ms
53,516 KB
testcase_23 AC 39 ms
53,516 KB
testcase_24 AC 42 ms
53,516 KB
testcase_25 AC 41 ms
53,516 KB
testcase_26 AC 40 ms
53,516 KB
testcase_27 AC 40 ms
53,516 KB
testcase_28 AC 40 ms
53,516 KB
testcase_29 AC 40 ms
53,516 KB
testcase_30 AC 40 ms
53,516 KB
testcase_31 AC 40 ms
53,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def floor_sum(n,m,a,b):
    res = 0
    while True:
        res += ((n-1)*n*(a//m)//2) + (b//m)*n
        a %= m
        b %= m
        if a*n+b <= m:
            return res
        Y = (a*n+b)//m
        n,m,a,b = Y,a,m, a*n + b - m*Y

"""
ax + by <= t, x >= 0, y >= 0 をみたす x,y の個数
"""
def points_in_triange(a,b,t):
    return floor_sum(1+t//a,b,a,t-t//a*a) + t//a + 1

a,b,t = map(int,input().split())
r = points_in_triange(a,b,t-1)
ng = t-1
ok = 10**12
while ok-ng > 1:
    mid = (ok+ng)//2
    if r < points_in_triange(a,b,mid):
        ok = mid
    else:
        ng = mid
print(ok)
0