結果

問題 No.2001 Distanced Triple
ユーザー ygd.ygd.
提出日時 2022-07-09 11:30:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,207 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 71,648 KB
最終ジャッジ日時 2023-08-28 22:04:20
合計ジャッジ時間 4,440 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,276 KB
testcase_01 AC 74 ms
71,548 KB
testcase_02 AC 73 ms
71,328 KB
testcase_03 AC 74 ms
71,348 KB
testcase_04 AC 73 ms
71,236 KB
testcase_05 AC 72 ms
71,336 KB
testcase_06 AC 74 ms
71,412 KB
testcase_07 AC 72 ms
71,432 KB
testcase_08 AC 75 ms
71,324 KB
testcase_09 AC 72 ms
71,472 KB
testcase_10 AC 74 ms
71,280 KB
testcase_11 AC 72 ms
71,316 KB
testcase_12 AC 74 ms
71,496 KB
testcase_13 AC 73 ms
71,220 KB
testcase_14 AC 73 ms
71,572 KB
testcase_15 AC 74 ms
71,408 KB
testcase_16 AC 72 ms
71,416 KB
testcase_17 AC 75 ms
71,432 KB
testcase_18 AC 74 ms
71,360 KB
testcase_19 AC 72 ms
71,648 KB
testcase_20 AC 75 ms
71,276 KB
testcase_21 AC 75 ms
71,364 KB
testcase_22 AC 72 ms
71,436 KB
testcase_23 AC 73 ms
71,272 KB
testcase_24 AC 72 ms
71,052 KB
testcase_25 AC 72 ms
71,280 KB
testcase_26 AC 72 ms
71,328 KB
testcase_27 AC 74 ms
71,208 KB
testcase_28 AC 74 ms
71,544 KB
testcase_29 AC 74 ms
71,648 KB
testcase_30 AC 74 ms
71,316 KB
testcase_31 AC 74 ms
71,416 KB
testcase_32 AC 75 ms
71,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy
#import math
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

inv2 = pow(2,MOD-2,MOD)
inv6 = pow(6,MOD-2,MOD)

def sumk(a):
    return a*(a+1)%MOD*inv2%MOD

def sumk2(a):
    return a*(a+1)%MOD*(2*a+1)%MOD*inv6%MOD

def main():
    L,R = map(int,input().split())
    A,B,C = map(int,input().split())

    btm = max(A+B,C)
    top = R - L

    if btm > top:
        print(0);exit()

    beta = top + 1
    alpha = 1 - (B+A)

    #print(top,btm)

    left = top+1-(B+A)
    right = (top+1-btm)
    #print(left,right)

    ans = 0
    ans -= sumk2(top) - sumk2(btm-1)
    #print(ans)
    ans += (beta - alpha) * (sumk(top) - sumk(btm-1)) %MOD
    #print(ans)
    ans += alpha * beta %MOD * (top - btm + 1) %MOD

    print(ans%MOD)


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