QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#1254. הקבוצה הגדולה ביותר אי פעם

Statistics

קבוצה של מספרים שלמים אי־שליליים היא נאה אם ורק אם כל המספרים בקבוצה קטנים מ־$T$ וסכומם שקול ל־$rem$ מודולו $n$. משימתכם היא למצוא את מספר הקבוצות הנאות השונות.

קלט

השורה הראשונה של הקלט מכילה את המספרים השלמים $n$ ו־$rem$, המופרדים ברווח ($0 \le rem < n \le 10^4$). השורה השנייה של הקלט מכילה מספר שלם יחיד $T$ ($1 \le T \le 10^{100\,000}-1$).

פלט

הדפיסו את מספר הקבוצות הנאות השונות. מכיוון שמספר זה עשוי להיות גדול מאוד, יש להדפיס אותו מודולו המספר הראשוני $998\,244\,353$.

דוגמאות

קלט 1

3 2
5

פלט 1

8

קלט 2

1 0
20

פלט 2

1048576

הערה

בדוגמה הראשונה אפשר לכלול את המספרים $0$ ו־$3$ או להשמיטם באופן חופשי, בלי לשנות את השארית. מבין המספרים $\{1,2,4\}$ יש שתי קבוצות נאות: $\{2\}$ ו־$\{1,4\}$. לכן התשובה היא $2 \cdot 2 \cdot 2 = 8$.

בדוגמה השנייה כל תת־קבוצה של $\{0,1,\ldots,19\}$ היא נאה, ולכן התשובה היא $2^{20} = 1\,048\,576$.

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.