Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

題目描述

有 $N$ 個人報名參加咗一場聲優見面會。要報名參加呢個活動,每個人必須買 $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.