QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 512 MB Puntuación total: 100

#18047. 有标号连通图

Estadísticas

给定一个整数 $n$ 和一个质数模数 $m$。

计算在所有不同的、含有 $n$ 个顶点的有标号连通图中,第 1 个顶点和第 2 个顶点之间距离的和。

输出任何在模 $m$ 意义下与实际和同余的整数。形式化地,如果实际的和为 $S$,输出任何满足 $-2^{63} \le x < 2^{63}$ 且 $x - S$ 能被 $m$ 整除的整数 $x$。

输入格式

唯一的一行包含两个整数 $n$ 和 $m$($2 \le n \le 400$,$10^6 + 3 \le m \le 10^9 + 9$,$m$ 为质数),分别表示图的顶点数和模数。

输出格式

输出一个整数 —— 问题的答案。

样例

输入样例 1

2 998244353

输出样例 1

1

输入样例 2

3 1001177

输出样例 2

5

输入样例 3

4 1000003

输出样例 3

54

输入样例 4

5 1000159

输出样例 4

1108

输入样例 5

6 1000253

输出样例 5

41880

输入样例 6

7 100000007

输出样例 6

2946440

输入样例 7

10 100001303

输出样例 7

82834735

输入样例 8

25 100002013

输出样例 8

77432340

输入样例 9

31 100001887

输出样例 9

7237626

输入样例 10

42 100002593

输出样例 10

44678783

输入样例 11

68 31235417

输出样例 11

22825855

输入样例 12

117 12345847

输出样例 12

4325099

输入样例 13

200 1000000007

输出样例 13

194453485

输入样例 14

228 12348143

输出样例 14

6438982

输入样例 15

300 34569361

输出样例 15

24221941

输入样例 16

312 34570903

输出样例 16

12146306

输入样例 17

322 41236777

输出样例 17

26590080

输入样例 18

350 41237641

输出样例 18

40908795

输入样例 19

366 66666667

输出样例 19

57608403

输入样例 20

378 99000007

输出样例 20

61227322

输入样例 21

399 99990001

输出样例 21

46973248

输入样例 22

400 1000000009

输出样例 22

478599227

说明

如果你在这道题上得到了 WA(答案错误),并且我们有合理的理由相信你不是故意为之,我们可能会以某种方式给你一块饼干。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.