Special sets
Practice
3.6 (54 votes)
2d dynamic programming
Algorithms
Dynamic programming
Medium
Permutation and combination
Problem
86% Success 8319 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

An ordered set is a set such that the order in which the objects appear in the set is significant.

For example, (\(1,\ 2,\ 3\)) and (\(2,\ 3,\ 1\)) are two different ordered sets of integers.

An ordered set \(S\) of integers is said to be a special set if for every element \(X\) of the set, the set does not contain the element \(X+1\)

You are given an integer \(N\). Determine the number of special sets whose largest element is not greater than \(N\). Since, the number of special sets can be very large, print the answer modulo \(1000000007\).

For example, if \(N = 3\), then there are \(5\) special sets that are (\(1\)), (\(2\)), (\(3\)), (\(1, 3\)), (\(3, 1\)).

Input format

A single Integer \(N\)

Output format

A single integer representing the number of special sets that satisfy the provided conditions.

Constraints

\(1 \leq N \leq 2000\) 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
10 votes
Tags:
AlgorithmsDynamic ProgrammingGrammar-VerifiedImplementationMediumTwo dimensional
Points:30
7 votes
Tags:
Depth First SearchDynamic ProgrammingMediumTwo dimensionalapprovedmatrix
Points:30
19 votes
Tags:
AlgorithmsDynamic Programming2D dynamic programming