QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 512 MB 満点: 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

資料範圍

記 $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$ 的所有答案。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.