CCO Preparation Test 2 P3 - Subsets

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 128M

Author:
Problem types

When Bruce learned set theory, he assigned a homework question to his students.

Given a positive integer N, find the number of subsets of the whole set {1,2,,N} that satisfies the following constraint: if an integer x is in the subset, then the integers 2x and 3x are not in the subset. For example, given N=4, the whole set is {1,2,3,4}. The number of subsets satisfying the constraint is 8, including the empty set: , {1}, {1,4}, {2}, {2,3}, {3}, {3,4}, and {4}.

Input Specification

The input will consist of one integer N (1N100000).

Output Specification

Output the number of subsets that satisfy the above constraints mod 1000000001 (=109+1).

Sample Input

Copy
4

Sample Output

Copy
8

Comments

There are no comments at the moment.