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

Deputy General

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 451    Accepted Submission(s): 149


Problem Description
War is cruel .Every one has a boss except LvBu. LvBu want to rally the troops to make his army stronger .
The rule is: everyone may have 0~2 deputy generals and must have only one boss(except LvBu).Everyone has his own level(all levels are different),and his deputy generals' level must less than his. You can assume no one is more levelful than LvBu.
For example , LvBu's level is 4,ChenGong's level is 3,ZhangLiao's level is 2 and GaoShun's level is 1.So,We can make five way :

Now ,give you the number of generals in LvBu's army.Please tell me the number of possible methods?
The answer might be very large. Output your answers mod k.
 

Input
Each line contains two integers n and k, indicating the number of LvBu's generals (including LvBu).
1<= n <= 1000;2<=k<=1,000,000,000
 

Output
For each case, output an answer mod k.
 

Sample Input
1 10007 2 10007 3 10007 4 10007
 

Sample Output
1 1 2 5
 

Author
sh¨£áÌ
 

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-11-22 11:11:37, Gzip enabled