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

Equation

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 901    Accepted Submission(s): 336


Problem Description
Gorwin is very interested in equations. Nowadays she gets an equation like this
${x_1} + {x_2} + {x_3} + \cdots + {x_n} = n$, and here \[\begin{array}{l}
0 \le {x_i} \le n{\kern 1pt} {\kern 1pt} {\kern 1pt} for{\kern 1pt} {\kern 1pt} {\kern 1pt} 1 \le i \le n\\
{x_i} \le {x_{i + 1}}{\kern 1pt} \le {x_i} + 1{\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} for{\kern 1pt} {\kern 1pt} {\kern 1pt} 1 \le i \le n - 1
\end{array}\]
For a certain $n$, Gorwin wants to know how many combinations of $xi$ satisfies above condition.
For the answer may be very large, you are expected output the result after it modular $m$.
 

Input
Multi test cases. The first line of the file is an integer $T$ indicates the number of test cases.
In the next $T$ lines, every line contain two integer $n, m$.

[Technical Specification]
$1 \leq T < 20$
$1 \leq n \leq 50000$
$1 \leq m \leq 1000000000$
 

Output
For each case output should occupies one line, the output format is Case #id: ans, here id is the data number starting from 1, ans is the result you are expected to output.
See the samples for more details.
 

Sample Input
2 3 100 5 100
 

Sample Output
Case #1: 2 Case #2: 3
 

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-04-16 19:41:53, Gzip enabled