Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

設 $x$ 是一個在 $r$ 進位下由 $n$ 個相同的數位 $a$ 所表示的整數。同時,設 $y$ 是一個在 $r$ 進位下表示由 $m$ 個數位 $b$ 所組成的整數。

求數字 $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.