結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineqconvexineq
提出日時 2021-01-23 14:48:12
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 543 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 82,028 KB
最終ジャッジ日時 2023-08-29 01:44:05
合計ジャッジ時間 6,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
81,116 KB
testcase_01 AC 81 ms
75,548 KB
testcase_02 AC 79 ms
75,584 KB
testcase_03 AC 79 ms
75,588 KB
testcase_04 AC 82 ms
75,736 KB
testcase_05 AC 80 ms
75,480 KB
testcase_06 AC 253 ms
77,296 KB
testcase_07 AC 249 ms
77,208 KB
testcase_08 AC 247 ms
76,932 KB
testcase_09 AC 206 ms
76,912 KB
testcase_10 AC 190 ms
77,296 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-t//a*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(a,b,t) - points_in_triange(a,b,t-1)
    print(ans)
0