#P8395. [CCC 2022 S1] Good Fours and Good Fives

    ID: 9478 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>动态规划 DP2022枚举CCC(加拿大)

[CCC 2022 S1] Good Fours and Good Fives

Problem Description

Finn\rm Finn really likes 44 and 55. He believes that every number can be obtained by adding 44 and 55.

Examples:

14=5+5+414 = 5 + 5 + 4

20=4+4+4+4+420 = 4 + 4 + 4 + 4 + 4 or 20=5+5+5+520 = 5 + 5 + 5 + 5

40=4+4+4+4+4+4+4+4+4+440 = 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 or 40=4+4+4+4+4+5+5+5+540 = 4 + 4 + 4 + 4 + 4 + 5 + 5 + 5 + 5 or 40=5+5+5+5+5+5+5+540 = 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5

Of course, the order of 44 and 55 does not matter; what matters is how many of each you use.

Given a positive integer nn, ask how many ways there are to form nn using 44 and 55.

Input Format

One line containing an integer nn, which is the number to be formed.

Output Format

One line containing the number of ways. If this number cannot be formed, output 00.

14
1
40
3
6
0

Hint

For 20%20\% of the testdata: 1n101 \le n \le 10.

For another 15%15\% of the testdata: 1n1051 \le n \le 10^5, and it is guaranteed that n0(mod4)n \equiv 0 \pmod 4.

For another 15%15\% of the testdata: 1n1051 \le n \le 10^5, and it is guaranteed that n0(mod5)n \equiv 0 \pmod 5.

For 100%100\% of the testdata: 1n1061 \le n \le 10^6.

Translated by ChatGPT 5