Logo
(追記) (追記ここまで)

6182번 - Roads Around The Farm 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB182917853.425%

문제

Farmer John's cows have taken an interest in exploring the territory around the farm. Initially, all N (1 <= N <= 1,000,000,000) cows commence traveling down a road in one big group. Upon encountering a fork in the road, the group sometimes chooses to break into two smaller (nonempty) groups with each group continuing down one of the roads. When one of those groups arrives at another fork, it might split again, and so on.

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

제한

예제 입력 1

6 2

예제 출력 1

3

힌트

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

 6
 / \
 2 4
 / \
 1 3

출처

Olympiad > USA Computing Olympiad > 2007-2008 Season > USACO US Open 2008 Contest > Silver 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /