Universal Cup Judging System

Universal Cup

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

נתונים המספרים השלמים $N, X, Y, K$ ו-$M$. מצאו את מספר השלשות $(A, B, C)$ של סדרות מספרים שלמים באורך $N$ המקיימות את כל התנאים הבאים, מודולו $M$.

  • עבור כל $i = 1, 2, \dots, N$, השלשה $(A_i, B_i, C_i)$ היא תמורה של $(1, 2, 3)$.
  • הסדרה $A$ מכילה בדיוק $X$ מופעים של $1$ ו-$Y$ מופעים של $2$.
  • סכום מספרי ההיפוכים של $A$, $B$ ו-$C$ שווה ל-$K$.

כאן, מספר ההיפוכים של סדרה $a$ מוגדר כמספר הזוגות של מספרים שלמים $(i, j)$ המקיימים $1 \le i < j \le |a|$ וכן $a_i > a_j$.

קלט

הקלט ניתן בפורמט הבא:

N X Y K M
  • כל ערכי הקלט הם מספרים שלמים.
  • $2 \le N \le 50$.
  • $0 \le X, Y \le N$.
  • $X + Y \le N$.
  • $0 \le K \le \frac{3}{2}N(N - 1)$.
  • $10^8 \le M \le 10^9$.

פלט

הדפיסו את התשובה.

דוגמה 1

3 1 1 4 998244353
24

דוגמה 2

4 0 0 18 123456789
0

דוגמה 3

50 10 20 1000 1000000000
805988728

הערה

בדוגמה הראשונה, ישנן $24$ שלשות $(A, B, C)$ המקיימות את התנאים. לדוגמה, אם ניקח $A = (1, 2, 3)$, $B = (3, 3, 2)$ ו-$C = (2, 1, 1)$, אזי $(A, B, C)$ מקיימת את כל התנאים.

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.