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
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #114: Counting block combinations I

Project Euler #114: Counting block combinations I

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 114 from projecteuler.net

A row measuring units in length has red blocks with a minimum length of units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square. There are exactly seventeen ways of doing this for and .

How many ways can a row measuring units in length be filled? As the answer can be extremely large, print it modulo .

NOTE: Although the example above does not lend itself to the possibility, in general it is permitted to mix block sizes. For example, on a row measuring eight units in length (and ) you could use red (), black (), and red ().

Input Format

The input contains two space separated integers and .

Constraints

Output Format

Print one integer - the answer to a problem modulo .

Sample Input

7 3

Sample Output

17

Author

Alex_2oo8

Difficulty

Medium

Max Score

100

Submitted By

377

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature