QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#351. 直至世界化作灰烬

统计

Node. 如果无解,输出 -1

譲れない夢なら私にも きっとある 信じてる 
不容退让的梦想我也有 坚信你和我今后的可能

高鳴るこの胸の奥深く 灯ったの 静かに情熱が 今 
那潜藏心底的炙热情感 涌上心头轰鸣喷出之时 就在此刻

  99届,愛城華恋,「世界を灰にするまで」《少女歌剧 Revue Starlight》

给你一个数 $x$,请你找到最小的 $y$,使得 $y + y\texttt{.reverse()} = x$,或者指出无解。注意此处的 reverse() 意指将 $y$ 的字符串翻转得到的数,$y$ 不能有前导零,但是 $y\texttt{.reverse()}$ 可以。

输入格式

第一行输入一个正整数 $T$,表示数据组数。

接下来每行一个非负整数 $x$,表示询问的数。

输出格式

输出 $T$ 行,每行一个非负整数 $y$ 表示对应的答案。

样例数据

样例 1 输入

5
3982
198
121
1017610
1998

样例 1 输出

1991
99
29
107909
999

数据范围

空间限制:$512\texttt{MB}$

时间限制:$2\texttt{s}$

记 $L$ 为 $x$ 输入串的长度。

对于 $20\%$ 的数据,保证 $L\le 5$。

对于 $40\%$ 的数据,保证 $L\le 50$。

对于 $60\%$ 的数据,保证 $L\le 1,000$。

对于 $100\%$ 的数据,保证 $1\le T\le 5, 1\le L\le 10^6$。

提示

本题的下发样例涵盖了 $0\le x\le 9,999$ 的所有答案。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.