CF2234B.Palindrome, Twelve and Two Terms

入门

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a positive integer nn. A pair of non-negative integers a,ba, b is called beautiful if the following conditions hold:

  • a+b=na + b = n.
  • The number aa is a palindrome.∗^{\text{∗}}
  • The number bb is divisible by 1212.

You need to find a beautiful pair or report that it does not exist.

∗^{\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 1232112321, 67766776, 55, 00 are palindromes, while the numbers 123123 and 6969 — are not.

给你一个正整数 nn。一对非负整数 a,ba, b 被称为优美对,当且仅当满足以下条件:

  • a+b=na + b = n;
  • 数 aa 是一个回文数∗^{\text{∗}};
  • 数 bb 能被 1212 整除。

你需要找出一个优美对,或者判断其不存在。

∗^{\text{∗}}一个数被称为回文数,当且仅当它在十进制表示下的各位数字逆序排列后仍与原数相同。例如,1232112321、67766776、55、00 是回文数,而 123123 和 6969 不是。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The only line of each test case contains a single integer nn (1≤n≤10181 \leq n \leq 10^{18}).

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例仅有一行,包含一个整数 nn(1≤n≤10181 \leq n \leq 10^{18})。

输出格式

For each test case, if such aa and bb exist, output aa and bb on a separate line, separated by a space. Otherwise, output −1-1 on a separate line.

If there are several beautiful pairs a,ba, b, you may output any of them.

对于每个测试用例,如果存在满足条件的 aa 和 bb,则在单独一行上输出 aa 和 bb,二者之间用一个空格分隔;否则,在单独一行上输出 −1-1。

如果存在多个优美的数对 (a,b)(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=1a = 1 is a palindrome, and b=0b = 0 is divisible by 1212, and a+b=1=na + b = 1 = n, so the answer satisfies the condition.

In the second test case, it can be shown that no pair a,ba, b is suitable.

In the third test case, a=262a = 262 is a palindrome, and b=48b = 48 is divisible by 1212, and a+b=310=na + b = 310 = n, so the answer satisfies the condition.

在第一个测试用例中,a=1a = 1 是一个回文数,b=0b = 0 能被 1212 整除,且 a+b=1=na + b = 1 = n,因此该答案满足条件。

在第二个测试用例中,可以证明不存在满足条件的数对 a,ba, b。

在第三个测试用例中,a=262a = 262 是一个回文数,b=48b = 48 能被 1212 整除,且 a+b=310=na + b = 310 = n,因此该答案满足条件。

输入解题思路,AI测评打分。不知道怎么写?

首页