Universal Cup Judging System

Universal Cup

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

問題文

声優のトークイベントに $N$ 人が応募しました。このイベントに応募するには $1$ 枚以上 $4$ 枚以下のチケットを購入する必要があり、$i$ 枚のチケットを購入した人は $T_i$ 人います($1 \le i \le 4$)。ここで、人は購入したチケットの枚数によってのみ区別され、同じ枚数のチケットを購入した人同士は区別できないものとします。

このトークイベントでは、抽選に当選した人は、購入したチケットの枚数に等しい時間だけ声優と話すことができます。

イベントの総時間は $X$ 単位時間です。乱数の神であるパフィン・パタロウは、合計時間がイベント時間を超えないように(言い換えると、当選者が購入したチケットの枚数の総和が高々 $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

注記

チケットを $i$ 枚購入した人のうちの当選者数を $t_i$ とします。1 番目のテストケースでは、条件を満たす選び方は以下の $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)$

2 番目のテストケースでは、条件を満たす選び方は存在しません。

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.