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$ からなる整数とします。

$r$ 進法で表された数 $z = x \cdot y$ の各桁の数字の和を求め、その和も $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.