QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#6203. 三色树

統計

请你对满足以下要求的 $n$ 个节点的 无标号无根树 计数:

  1. 每个节点是三种颜色之一:红,蓝,黄
  2. 红色节点度数不超过 $4$,蓝色和黄色节点度数均不超过 $3$
  3. 黄色节点不能相邻

注意 无标号无根树 的意义是:如果两颗树可以通过重新编号的方法使得对应点颜色相同,对应连边一致,则认为是同一颗树。

答案对输入的质数 $P$ 取模。

输入格式

两个整数,$n, P$ 意义如题面所示。

输出格式

一个整数,表示方案数对 $P$ 取模的结果。

样例一

input

2 998244353

output

5

样例二

input

3 998244353

output

15

样例三

input

20 998244353

output

578067492

限制与约定

对于 $100\%$ 的数据,保证 $1\le n \le 3000, 9\times 10^8 \le P \le 1.01\times 10^9$

测试点编号$n$ 是偶数,$P = 998244353$$n$ 是奇数,$P = 998244353$$n$ 是偶数$n$ 是奇数
$n\le 7$$1$$2$$3$$4$
$n\le 20$$5$$6$$7$$8$
$n\le 60$$9$$10$$11$$12$
$n\le 300$$13$$14$$15$$16$
$n\le 3000$$17$$18$$19$$20$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.