#P6065. [USACO05JAN] Sumsets S

[USACO05JAN] Sumsets S

Description

Given an integer NN, how many ways are there to decompose NN into a sum of several powers of 22?

Input Format

Input an integer NN (1N1061 \leq N \leq 10^6).

Output Format

Output the number of valid decompositions modulo 10910^9.

7
6

Hint

All valid decompositions are as follows.

  • 1+1+1+1+1+1+1
  • 1+1+1+1+1+2
  • 1+1+1+2+2
  • 1+1+1+4
  • 1+2+2+2
  • 1+2+4

Translated by ChatGPT 5