Description
We know that a number is divisible by 3 if and only if the sum of its digits is divisible by 3. We also know that a number is divisible by 11 if and only if the difference between the sum of the odd numbered digits (1st, 3rd, 5th...) and the sum of the even numbered digits (2nd, 4th...) is divisible by 11. However, these rules are only for decimal (base-10) numbers. In base-b, there are numbers similar to 3 and 11 in decimal. Your task is to find the smallest x and y, where x is similar to 3 in base-b and y is similar to 11 in base-b. Formally, you are to find the smallest x and y (x, y > 1), so that a base-b number n = ak * bk + ak-1 * bk-1 + ... + a1 * b + a0 is divisible by x if and only if ak + ... + a0 is divisible by x, and n is divisible by y if and only if (a0 + a2 + ...) - (a1 + a3 + ...) is divisible by y.
Input
The first line is a single integer T (1 <= T <= 100), indicating the number of test cases.
For each test case, there is only one positive integer b (3 <= b <= 10^6), the base.
Output
For each test case, output the x and y in a line, separated by a single space. The x and y
should be presented in decimal.
Sample Input
2 10 120
Sample Output
3 11 7 11 |
SicilyOJ 11珠海赛重现 E.Divisibility(数学)
最新推荐文章于 2024-03-19 15:59:13 发布