結果

問題 No.2001 Distanced Triple
ユーザー Navier_Boltzmann
提出日時 2022-07-10 12:52:47
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2025-01-02 23:29:50
合計ジャッジ時間 2,679 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from functools import *
from itertools import *
from heapq import *
import sys
input = sys.stdin.readline
mod = 998244353

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

M = max(A+B,C)
D = R-L
if D<M:
    print(0)
    exit()
ans = 0
E = D-A-B+1
ans += E*(D-M+1)
ans += (D-A-B)*(D-M+1)*(D-M)//2
ans -= (D-M)*(D-M+1)*(2*D-2*M+1)//6
print(ans%mod)
0