QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#351. 世界が灰になるまで

الإحصائيات

ヒント:解が存在しない場合は -1 を出力してください。

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

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

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

与えられた数 $x$ に対して、$y + y\texttt{.reverse()} = x$ を満たす最小の $y$ を求めてください。解が存在しない場合は -1 を出力してください。ここで reverse() は $y$ を文字列として反転させた数を指します。$y$ に前導零(leading zero)を含めることはできませんが、$y\texttt{.reverse()}$ には含めることができます。

入力

1 行目にデータセットの数 $T$ が与えられます。

続く各行に、クエリとなる非負整数 $x$ が与えられます。

出力

$T$ 行にわたって、各クエリに対する答えである非負整数 $y$ を出力してください。

入出力例

入力 1

5
3982
198
121
1017610
1998

出力 1

1991
99
29
107909
999

制約

$x$ の入力文字列の長さを $L$ とします。

  • $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.