Universal Cup Judging System

Universal Cup

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

יהי $x$ מספר שלם המיוצג על ידי $n$ ספרות זהות $a$ בבסיס $r$. כמו כן, יהי $y$ מספר שלם שהייצוג שלו מורכב מ-$m$ ספרות $b$ בבסיס $r$.

מצא את סכום הספרות של המספר $z = x \cdot y$ המיוצג בבסיס $r$, והדפס גם את סכום הספרות הזה בבסיס $r$.

קלט

השורה הראשונה מכילה מספר שלם יחיד $t$ ($1 \le t \le 10\,000$): מספר מקרי הבדיקה. אחריה מופיע תיאור מקרי הבדיקה.

כל מקרה בדיקה מורכב משורה אחת המכילה חמישה מספרים שלמים $n, m, a, b, r$ ($n, m \ge 1, n + m \le 10^{18}, 1 \le a, b < r \le 10$).

פלט

עבור כל מקרה בדיקה, הדפס מספר שלם יחיד בשורה נפרדת: התשובה לבעיה בבסיס $r$.

דוגמה

קלט לדוגמה 1

5
2 3 6 6 10
6 11 7 7 10
20 25 2 6 10
13 37 1 1 2
57 1 4 2 8

פלט לדוגמה 1

27
84
204
100101
71

הערה

במקרה הבדיקה הראשון, מתקיים $x = 66_{10}, y = 666_{10}, z = 43\,956_{10}$. סכום הספרות של $z$ הוא $27_{10}$.

במקרה הבדיקה הרביעי, סכום הספרות של $z$ בייצוג בינארי הוא $37_{10} = 100101_2$.

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.