結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー convexineq
提出日時 2021-01-23 14:56:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 538 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 135,808 KB
最終ジャッジ日時 2024-12-30 19:52:22
合計ジャッジ時間 20,600 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

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