#9207. [USACO08OPEN] Roads Around The Farm S

[USACO08OPEN] Roads Around The Farm S

[USACO08OPEN] Roads Around The Farm S

题目描述

Farmer John's cows have taken an interest in exploring the territory around the farm. Initially, all N (1 <= N

The cows have crafted a peculiar way of splitting: if they can split into two groups such that the sizes of the groups differ by exactly K (1 <= K <= 1000), then they will split in that way; otherwise, they stop exploring and just start grazing peacefully.

Assuming that there will always be new forks in the road, compute the final number of groups of peacefully grazing cows.

输入格式

\* Line 1: Two space-separated integers: N and K

输出格式

\* Line 1: A single integer representing the number of groups of grazing cows
6 2 
3 

提示

There are 6 cows and the difference in group sizes is 2.

There are 3 final groups (with 2, 1, and 3 cows in them).

  6
 / \
2   4
   / \
  1   3

标签: P2907|2008|USACO|递归

来源

P2907|[USACO08OPEN] Roads Around The Farm S