QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#18485. 数学は体育科目です 3

Statistiques

イファンは第4次産業革命時代に生きる天才的な5歳の赤ん坊である。ある日、幼稚園の先生はイファンの天才性に気づき、次のような問題を彼に出した。

「$A$ 以上 $B$ 以下の整数をすべて足した値はいくつになるかな?」

イファンは天才ではあるが、まだ赤ん坊なので足し算が何であるかをよく知らない。翌日、イファンはノートに $A$ 以上 $B$ 以下のすべての整数を、大きさの順にスペースを空けずに書き並べて持ってきた。例えば、$A = 4$、$B = 21$ の場合、イファンが書いてきた答えは 456789101112131415161718192021 のようになる。

イファンは並外れた課題への執着心を持つ天才だが、イファンの先生はそうではない。実は、イファンの先生は昨日自分が言った2つの数が何であったかを忘れてしまった。先生が覚えている情報は、$A$ と $B$ はどちらも $1$ 以上 $999$ 以下の整数であり、当然 $A$ は $B$ 以下であったということだけである。

イファンが書いてきた数字の列が与えられたとき、先生が言った2つの数を求めることができるだろうか?

入力

1行目に、イファンが書いてきた答えを表す文字列 $S$ が与えられる。$S$ は数字(09)のみからなり、長さは $1$ 以上 $2\,889$ 以下である。

出力

イファンの先生が言った2つの整数 $A$ と $B$ を空白で区切って出力せよ。もし可能な答えが2つ以上ある場合は、そのうち $A$ が最も小さいものを出力せよ。

イファンは常に正確な答えを書くため、問題の条件を満たす答えが存在する入力のみが与えられる。

入出力例

入力 1

9101112

出力 1

9 12

入力 2

12

出力 2

1 2

入力 3

999

出力 3

999 999

入力 4

456789101112131415161718192021

出力 4

4 21

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.