题库练习 Symmetric and Transitive
← 上一题 下一题 →

A10059 | Symmetric and Transitive

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.

A set $ρ$ of pairs $(a,b)$ of elements of some set $A$ is called a binary relation on set $A$ . For two elements $a$ and $b$ of the set $A$ we say that they are in relation $ρ$ , if pair ![](/uploads/luogu/CF568B/16a5bd0364ee1c2418519b45f507a656a36915fe_2917cd44c23a.png), in this case we use a notation ![](/uploads/acgo/image/0ac744694065af88_675fd303c00a.jpeg).

Binary relation is equivalence relation, if:

1. It is reflexive (for any $a$ it is true that ![](/uploads/acgo/image/867d84158fc96aea_2054a41cf20d.jpeg));
2. It is symmetric (for any $a$ , $b$ it is true that if ![](/uploads/acgo/image/0ac744694065af88_675fd303c00a.jpeg), then ![](/uploads/acgo/image/ac49a7ffadd1b2df_2434e5caf91e.jpeg));
3. It is transitive (if ![](/uploads/acgo/image/0ac744694065af88_675fd303c00a.jpeg) and ![](/uploads/luogu/CF568B/5fd1e1be872bf420a3d068d47d57fec967b2dcb8_aa9da7dae8fc.png), than ![](/uploads/acgo/image/845c16215288e862_5f4dc506fcf6.jpeg)).

Little Johnny is not completely a fool and he noticed that the first condition is not necessary! Here is his "proof":

Take any two elements, $a$ and $b$ . If ![](/uploads/acgo/image/0ac744694065af88_675fd303c00a.jpeg), then ![](/uploads/acgo/image/ac49a7ffadd1b2df_2434e5caf91e.jpeg) (according to property (2)), which means ![](/uploads/acgo/image/867d84158fc96aea_2054a41cf20d.jpeg) (according to property (3)).

It's very simple, isn't it? However, you noticed that Johnny's "proof" is wrong, and decided to show him a lot of examples that prove him wrong.

Here's your task: count the number of binary relations over a set of size $n$ such that they are symmetric, transitive, but not an equivalence relations (i.e. they are not reflexive).

Since their number may be very large (not $0$ , according to Little Johnny), print the remainder of integer division of this number by $10^{9}+7$ .

输入格式

A single line contains a single integer $n$ $(1<=n<=4000)$ .

输出格式

In a single line print the answer to the problem modulo $10^{9}+7$ .

输入输出样例

输入 #1
1
输出 #1
1
输入 #2
2
输出 #2
3
输入 #3
3
输出 #3
10
C++ 编辑器
输入
输出