We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. P-sequences

P-sequences

Problem
Submissions
Leaderboard
Discussions
Editorial

We call a sequence of N natural numbers (a1, a2, ..., aN) a P-sequence, if the product of any two adjacent numbers in it is not greater than P. In other words, if a sequence (a1, a2, ..., aN) is a P-sequence, then ai * ai+1 ≤ P ∀ 1 ≤ i < N

You are given N and P. Your task is to find the number of such P-sequences of N integers modulo 109+7.

Input Format

The first line of input consists of N
The second line of the input consists of P.

Constraints

2 ≤ N ≤ 103
1 ≤ P ≤ 109
1 ≤ ai

Output Format

Output the number of P-sequences of N integers modulo 109+7.

Sample Input 0

2
2

Sample Output 0

3

Explanation 0

3 such sequences are {1,1},{1,2} and {2,1}

Author

zxqfd555

Difficulty

Hard

Max Score

100

Submitted By

2358

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

Join us

Create a HackerRank account

Be part of a 26 million-strong community of developers

Please signup or login in order to view this challenge

or
Already have an account?Log in