F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Matches Puzzle Game

Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 65535/102400 K (Java/Others)
Total Submission(s): 773    Accepted Submission(s): 516


Problem Description
As an exciting puzzle game for kids and girlfriends, the Matches Puzzle Game asks the player to find the number of possible equations $A - B = C$ with exactly $n~(5\le n\le 500)$ matches (or sticks).

In these equations, $A,B$ and $C$ are positive integers. The equality sign needs two matches and the sign of subtraction needs just one. Leading zeros are not allowed.

Please answer the number, modulo a given integer $m~(3\le m\le 2\times 10^9)$.
 

Input
The input contains several test cases. The first line of the input is a single integer $t$ which is the number of test cases. Then $t~(1\le t\le 30)$ test cases follow.

Each test case contains one line with two integers $n~(5\le n\le 500)$ and $m~(3\le m\le 2\times 10^9)$.
 

Output
For each test case, you should output the answer modulo $m$.
 

Sample Input
4 12 1000000007 17 1000000007 20 1000000007 147 1000000007
 

Sample Output
Case #1: 1 Case #2: 5 Case #3: 38 Case #4: 815630825
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-20 11:22:42, Gzip enabled