CF2234B.Palindrome, Twelve and Two Terms
入门
通过率:0%
时间限制:1.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive integer n. A pair of non-negative integers a,b is called beautiful if the following conditions hold:
- a+b=n.
- The number a is a palindrome.∗
- The number b is divisible by 12.
You need to find a beautiful pair or report that it does not exist.
∗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.
给你一个正整数 n。一对非负整数 a,b 被称为优美对,当且仅当满足以下条件:
- a+b=n;
- 数 a 是一个回文数∗;
- 数 b 能被 12 整除。
你需要找出一个优美对,或者判断其不存在。
∗一个数被称为回文数,当且仅当它在十进制表示下的各位数字逆序排列后仍与原数相同。例如,12321、6776、5、0 是回文数,而 123 和 69 不是。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The only line of each test case contains a single integer n (1≤n≤1018).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例仅有一行,包含一个整数 n(1≤n≤1018)。
输出格式
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.
If there are several beautiful pairs a,b, you may output any of them.
对于每个测试用例,如果存在满足条件的 a 和 b,则在单独一行上输出 a 和 b,二者之间用一个空格分隔;否则,在单独一行上输出 −1。
如果存在多个优美的数对 (a,b),你可以输出其中任意一个。
输入输出样例
输入#1
6 1 10 310 12 1000000000 6111111111111111
输出#1
1 0 -1 262 48 0 12 889989988 110010012 111111111111111 6000000000000000
说明/提示
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.
In the second test case, it can be shown that no pair a,b is suitable.
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=1 是一个回文数,b=0 能被 12 整除,且 a+b=1=n,因此该答案满足条件。
在第二个测试用例中,可以证明不存在满足条件的数对 a,b。
在第三个测试用例中,a=262 是一个回文数,b=48 能被 12 整除,且 a+b=310=n,因此该答案满足条件。
输入解题思路,AI测评打分。不知道怎么写?