Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

題目描述

有 $N$ 個人報名參加了一場聲優見面會(Talk Event)。要報名參加此活動,每個人必須購買 $1$ 到 $4$ 張(含)門票,且購買了 $i$ 張門票的人數為 $T_i$($1 \le i \le 4$)。在這裡,人僅透過他們購買的門票數量來區分;購買相同數量門票的人被視為是不可區分的。

在這次見面會中,如果一個人中籤,他們可以與聲優交流的時間等於他們購買的門票數量。

活動的總時長為 $X$ 個時間單位。隨機之神 Puffin Pataro 將選擇中籤者,使得總時長不超過活動時間(換句話說,中籤者購買的門票總數最多為 $X$)。然而,為了避免未被選中者的抱怨,必須滿足以下條件:

  • 對於任何未被選中的人,如果將該人額外選中,則總時長將超過活動時間。

求恰好選擇 $K$ 個中籤者的方案數,模 $998244353$。

請對 $\text{TESTCASES}$ 組測試資料求解此問題。

輸入格式

輸入按以下格式給出:

TESTCASES
case_1
case_2
:
case_T

每組測試資料按以下格式給出:

N K X
T_1 T_2 T_3 T_4
  • $1 \le \text{TESTCASES} \le 10^4$
  • $1 \le K \le N \le 2.5 \times 10^8$
  • $1 \le X \le 10^9$
  • $0 \le T_i$($1 \le i \le 4$)
  • $T_1 + T_2 + T_3 + T_4 = N$
  • 所有輸入值均為整數

輸出格式

輸出 $\text{TESTCASES}$ 行。

在第 $i$ 行中,輸出第 $i$ 組測試資料的答案。

範例

2
24 8 11
7 6 3 8
24 3 28
7 6 3 8
4
0

說明

設 $t_i$ 為購買了 $i$ 張門票的人當中的中籤人數。在第一組測試資料中,有以下 $4$ 種可能的選擇方案:

  • $(t_1, t_2, t_3, t_4) = (5, 3, 0, 0)$
  • $(t_1, t_2, t_3, t_4) = (6, 1, 1, 0)$
  • $(t_1, t_2, t_3, t_4) = (7, 0, 0, 1)$
  • $(t_1, t_2, t_3, t_4) = (7, 0, 1, 0)$

在第二組測試資料中,不存在滿足條件的選擇方案。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1493EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.