Codeforces Round 315 (Div. 1)
B
Symmetric and Transitive
Codeforces
1900
原题
← AC →
翻译中…

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 image, in this case we use a notation image.

翻译中…

Binary relation is equivalence relation, if:

翻译中…
  1. It is reflexive (for any $*a*$ it is true that image);
  2. It is symmetric (for any $*a*$, $*b*$ it is true that if image, then image);
  3. It is transitive (if image and image, than image).
翻译中…

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 image, then image (according to property (2)), which means image (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$.

翻译中…

Input

翻译中…

A single line contains a single integer $*n*$ $(1 ≤ *n* ≤ 4000)$.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

If $*n* = 1$ there is only one such relation — an empty one, i.e. image. In other words, for a single element $*x*$ of set $*A*$ the following is hold: image.

翻译中…

If $*n* = 2$ there are three such relations. Let's assume that set $*A*$ consists of two elements, $*x*$ and $*y*$. Then the valid relations are image, $ρ = {(*x*, *x*)}$, $ρ = {(*y*, *y*)}$. It is easy to see that the three listed binary relations are symmetric and transitive relations, but they are not equivalence relations.

翻译中…

样例

Input #1
1
Output #1
1
InputCopy OutputCopy
Input #2
2
Output #2
3
InputCopy OutputCopy
Input #3
3
Output #3
10
InputCopy OutputCopy
题目信息
题号
568B
时间限制
1.5 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。