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 #237: Tours on a 4 x n playing board

Project Euler #237: Tours on a 4 x n playing board

Problem
Submissions
Leaderboard
Discussions

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

Let be the number of tours over an playing board such that:

  • The tour starts in the top left corner;
  • The tour consists of moves that are up, down, left, or right one square;
  • The tour visits each square exactly once;
  • The tour ends in the bottom left corner.


The following diagram shows one tour over a board:

Define = . It can be shown that and .

Given integers and , what is ?
Since the answer can be quite large, express your solution modulo .

Input Format

Each test file contains 2 lines. The first line contains and the second .

Constraints

  • .
  • .

Output Format

Print the integer value of your answer modulo .

Sample Input 0

4
3

Sample Output 0

6

Explanation 0

It is easily seen that and . Also, since the case has the following four solutions:

image

Thus .

Author

kmcshane

Difficulty

Hard

Max Score

100

Submitted By

303

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