Universal Cup Judging System

Universal Cup

시간 제한: 2.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

คำอธิบาย

มีผู้สมัครเข้าร่วมงานทอล์กอีเวนต์ของนักพากย์จำนวน $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

หมายเหตุ

ให้ $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.