回文数、十二与两项AI (CI翻译)
You are given a positive integer $n$. A pair of non-negative integers $a, b$ is called beautiful if the following conditions hold:
给定一个正整数 $n$。如果一对非负整数 $a, b$ 满足以下条件,则称其为漂亮数对:AI (CI翻译)
$a + b = n$.- The number
$a$is a palindrome.$^{\text{∗}}$ - The number
$b$is divisible by$12$.
$a + b = n$。- 数字
$a$是回文数。$^{\text{∗}}$ - 数字
$b$能被$12$整除。
You need to find a beautiful pair or report that it does not exist.
你需要找出一组漂亮数对,或者报告不存在这样的数对。AI (CI翻译)
$^{\text{∗}}$A number is called a palindrome if and only if it remains the same when its digits (in decimal notation) are written in reverse order. For example, the numbers $12321$, $6776$, $5$, $0$ are palindromes, while the numbers $123$ and $69$ — are not.
$^{\text{∗}}$当且仅当一个数的数字(按十进制表示)倒序排列后仍与原数相同时,这个数才被称为回文数。例如,$12321$、$6776$、$5$、$0$ 是回文数,而 $123$ 和 $69$ 不是回文数。AI (CI翻译)
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
每个测试包含多个测试用例。第一行包含测试用例的数量 $t$($1 \le t \le 10^4$)。接下来是各测试用例的描述。AI (CI翻译)
The only line of each test case contains a single integer $n$ ($1 \leq n \leq 10^{18}$).
每个测试用例仅包含一行,其中包含一个整数 $n$($1 \leq n \leq 10^{18}$)。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, if such $a$ and $b$ exist, output $a$ and $b$ on a separate line, separated by a space. Otherwise, output $-1$ on a separate line.
对于每个测试用例,如果存在这样的 $a$ 和 $b$,则在单独一行中输出 $a$ 和 $b$,两者之间用空格分隔。否则,在单独一行中输出 $-1$。AI (CI翻译)
If there are several beautiful pairs $a, b$, you may output any of them.
如果存在多组漂亮数对 $a, b$,你可以输出其中任意一组。AI (CI翻译)
Note
说明
AI (CI翻译)In the first test case, $a = 1$ is a palindrome, and $b = 0$ is divisible by $12$, and $a + b = 1 = n$, so the answer satisfies the condition.
在第一个测试用例中,$a = 1$ 是回文数,$b = 0$ 能被 $12$ 整除,并且 $a + b = 1 = n$,因此该答案满足条件。AI (CI翻译)
In the second test case, it can be shown that no pair $a, b$ is suitable.
在第二个测试用例中,可以证明不存在合适的数对 $a, b$。AI (CI翻译)
In the third test case, $a = 262$ is a palindrome, and $b = 48$ is divisible by $12$, and $a + b = 310 = n$, so the answer satisfies the condition.
在第三个测试用例中,$a = 262$ 是回文数,$b = 48$ 能被 $12$ 整除,并且 $a + b = 310 = n$,因此该答案满足条件。AI (CI翻译)
样例
6
1
10
310
12
1000000000
6111111111111111
1 0
-1
262 48
0 12
889989988 110010012
111111111111111 6000000000000000
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。