#P6870. [COCI 2019/2020 #5] Zapina

    ID: 5521 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划,dp数学2020组合数学排列组合概率论,统计COCI

[COCI 2019/2020 #5] Zapina

Description

There are nn distinct people and nn distinct problems.

The ii-th person is happy if and only if they are assigned ii problems.

Find the number of assignment plans that make at least one person happy.

Input Format

One positive integer: nn.

Output Format

One number: your answer mod(109+7)\bmod(10^9+7).

1

1
2

3
314

192940893

Hint

Constraints

This problem uses bundled testdata.

  • For 2222 pts of testdata, 2n72\leq n\leq 7.
  • For another 3333 pts of testdata, 1n201\leq n\leq 20.
  • For all testdata, 1n3501\leq n\leq 350.

Sample #2 Explanation

There are the following 33 plans:

  • Give the first problem to the first person, and the second problem to the second person.

  • Give the second problem to the first person, and the first problem to the second person.

  • Give both problems to the second person.

Notes

Translated from COCI2019-2020 CONTEST #5 T5 Zapina, translated by 90693

Translated by ChatGPT 5