Universal Cup Judging System

Universal Cup

実行時間制限: 2.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

Gọi $x$ là một số nguyên được biểu diễn bởi $n$ chữ số $a$ giống hệt nhau trong hệ cơ số $r$. Đồng thời, gọi $y$ là một số nguyên có biểu diễn gồm $m$ chữ số $b$ trong hệ cơ số $r$.

Hãy tìm tổng các chữ số của số $z = x \cdot y$ khi biểu diễn trong hệ cơ số $r$, và đồng thời in ra tổng các chữ số này trong hệ cơ số $r$.

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên duy nhất $t$ ($1 \le t \le 10\,000$): số lượng bộ dữ liệu. Tiếp theo là mô tả của các bộ dữ liệu.

Mỗi bộ dữ liệu gồm một dòng duy nhất chứa năm số nguyên $n, m, a, b, r$ ($n, m \ge 1, n + m \le 10^{18}, 1 \le a, b < r \le 10$).

Kết quả

Với mỗi bộ dữ liệu, in ra một số nguyên duy nhất trên một dòng riêng biệt: đáp án của bài toán trong hệ cơ số $r$.

Ví dụ

Ví dụ 1 - Dữ liệu vào

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

Ví dụ 1 - Kết quả

27
84
204
100101
71

Giải thích

Ở bộ dữ liệu đầu tiên, ta có $x = 66_{10}, y = 666_{10}, z = 43\,956_{10}$. Tổng các chữ số của $z$ là $27_{10}$.

Ở bộ dữ liệu thứ tư, tổng các chữ số của $z$ trong biểu diễn nhị phân là $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.