Universal Cup Judging System

Universal Cup

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

$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.