codeforces 569 D. Symmetric and Transitive (bell数)
来源:互联网 发布:python 流对象如何传输 编辑:程序博客网 时间:2024/06/07 16:26
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 , in this case we use a notation .
Binary relation is equivalence relation, if:
- It is reflexive (for any a it is true that );
- It is symmetric (for any a, b it is true that if , then );
- It is transitive (if and , than ).
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 , then (according to property (2)), which means (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 109 + 7.
A single line contains a single integer n (1 ≤ n ≤ 4000).
In a single line print the answer to the problem modulo 109 + 7.
1
1
2
3
3
10
bell数
#include <iostream>#include <cstdio>#include <map>using namespace std;#define LL __int64const int MOD = 1000000007;LL T[4005],B[4005];void get_bell(int n,int mod){ B[0]=1; B[1]=1; T[0]=1; for(int i=2;i<=n;++i){ T[i-1]=B[i-1]; for(int j=i-2;j>=0;--j) T[j]=(T[j]+T[j+1])%mod; B[i]=T[0]; }}int main() {get_bell(4001, MOD);int n;cin>>n;LL a = B[n + 1];LL b = B[n];cout<<(a - b + MOD) % MOD<<endl;return 0;}
- [组合数+bell数] codeforces 569D. Symmetric and Transitive
- codeforces 569 D. Symmetric and Transitive (bell数)
- Codeforces Round #315 (Div. 1) B. Symmetric and Transitive(Bell数的应用)(好题)
- Codeforces Round #315 (Div. 2) D. Symmetric and Transitive
- Codeforces Round #315 (Div. 2)569D Symmetric and Transitive(dp)
- CodeForces #315 (div1) B.Symmetric and Transitive
- codeforces #315B. Symmetric and Transitive dp
- Codeforces Round #315 (Div. 1) B. Symmetric and Transitive 斯特林数 贝尔数
- codeforces 568B B. Symmetric and Transitive(贝尔数+组合数学)
- codeforces #568B Symmetric and Transitive 快速傅里叶变换
- CF 568B Symmetric and Transitive 贝尔数和stirlinig数
- Bell数
- Bell数
- bell数
- bell数
- Bell数
- Codeforces Round #445 D. Symmetric Projections
- 贝尔(Bell)数
- 着手使用ThinkPHP
- 京东联盟开通了
- 转载:一名程序员的磨练
- nasm : test instruction - test
- Android之Android Studio三种方式导入外部资源 以及 报错处理
- codeforces 569 D. Symmetric and Transitive (bell数)
- 笔记:Android-Content Provider
- CentOS 7 使用经验
- 安卓(android)开发框架的说明1:基于Eclipse的安卓工程开发目录介绍
- 我的蘑菇街面经(校招内推-收到offer)
- apt-get 源
- 求解一个字符串的所有字符的组合 Java代码
- 强连通图之HDU2767 Proving Equivalences
- 学习网关前理解网关