Submeter | Todas submissőes | Melhores | Voltar |
RATF - Roads Around The Farm |
English | Português |
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.
Input
- Line 1: Two space-separated integers: N and K
Output
- Line 1: A single integer representing the number of groups of grazing cows
Example
Input: 6 2
There are 6 cows and the difference in group sizes is 2.
Output: 3
There are 3 final groups (with 2, 1, and 3 cows in them).
6 / \ 2 4 / \ 1 3
Adicionado por: | Wanderley Guimarăes |
Data: | 2008-06-06 |
Tempo limite: | 0.100s |
Tamanho do fonte: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Linguagem permitida: | ADA95 DOC ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PDF PERL PHP PIKE PS PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE |
Origem: | USACO Open 2008 - Silver |