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)$ 头奶牛组成一个大群,沿着一条道路出发。遇到岔路时,牛群有时会分成两个较小的非空群,每群继续沿其中一条道路前进。当某个群到达另一个岔路时,它可能再次分裂,依此类推。

奶牛们制定了一种奇特的分群方式:如果能够分成两个群,使两群的大小恰好相差 $K$ $(1 \le K \le 1000)$,它们就这样分群;否则,它们停止探索,开始平静地吃草。

假设道路上总会有新的岔路,请计算最终平静吃草的牛群数量。

输入格式

  • 第 $1$ 行:两个以空格分隔的整数 $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.