QOJ.ac

QOJ

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

#22332. 農場の周りの道

Statistics

Farmer John の牛たちは農場周辺の地域の探索に興味を持ちました。最初はすべての $N$ $(1 \le N \le 1,000,000,000)$ 頭の牛が 1 つの大きな群れで道を進みます。分かれ道に出会うと、群れは 2 つのより小さい空でない群れに分かれ、それぞれの道を進むことがあります。その群れの 1 つが次の分かれ道に到達すると、再び分かれることがあり、これが続きます。

牛たちは変わった分かれ方を決めました。2 群の頭数の差がちょうど $K$ $(1 \le K \le 1000)$ となるように分かれられるなら、そのように分かれます。そうでなければ探索をやめて、穏やかに草を食べ始めます。

道には常に新しい分かれ道があると仮定して、最終的に穏やかに草を食べる群れの個数を求めてください。

入力

  • $1$ 行目:空白で区切られた 2 つの整数 $N$ と $K$。

出力

  • $1$ 行目:草を食べる群れの個数を表す整数。

入出力例

入力 1

6 2

出力 1

3

注記

牛は 6 頭いて、群れの頭数の差は 2 です。

最終的に 3 群になります(頭数はそれぞれ 2、1、3 です)。

   6
  / \
 2   4
    / \
   1   3

問題作成者:Aram Shatakhtsyan,2007

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.