結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineqconvexineq
提出日時 2021-01-23 14:56:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 538 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 81,632 KB
最終ジャッジ日時 2023-08-29 01:50:22
合計ジャッジ時間 5,926 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
77,128 KB
testcase_01 AC 78 ms
75,464 KB
testcase_02 AC 78 ms
75,916 KB
testcase_03 AC 77 ms
75,900 KB
testcase_04 AC 78 ms
75,548 KB
testcase_05 AC 79 ms
75,648 KB
testcase_06 AC 235 ms
77,636 KB
testcase_07 AC 219 ms
77,268 KB
testcase_08 AC 219 ms
77,224 KB
testcase_09 AC 192 ms
77,292 KB
testcase_10 AC 175 ms
77,384 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def floor_sum(n,m,a,b):
    res = 0
    while True:
        res += ((n-1)*n*(a//m)>>1) + (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

def points_in_triange(a,b,t):
    return floor_sum(1+t//a,b,a,t%a) + t//a + 1

T = int(input())
for _ in range(T):
    *abc,n = map(int,input().split())
    a,b,c = sorted(abc)
    ans = 0
    for t in range(n,-1,-c):
        ans += points_in_triange(b,a,t) - points_in_triange(b,a,t-1)
    print(ans)
0