http://codeforces.com/contest/568/problem/B

题意:题意还挺绕的,其实就是说:要你求出一个图,要求保证其中有至少一个点不连任何边,然后其他连边的点构成的每个联通块都必须构成完全连通图

思路:f[i][j]代表i个点,构成j个联通块的方案数

f[i][j]=f[i][j-1]*j(代表与其中一个联通块合并)+f[i-1][j-1](代表新开一个联通块)

然后答案是Σc[n][i]*f[i][j]

 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#define ll long long
const ll Mod=;
ll f[][],c[][];
int n;
ll Pow(ll x,ll y){
ll res=;
while (y){
if (y&) res=(res*x)%Mod;
y/=;
x=(x*x)%Mod;
}
return res;
}
int read(){
int t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();
ll ans=;
for (int i=;i<=n;i++) c[i][]=c[i][i]=;
for (int i=;i<=n;i++)
for (int j=;j<i;j++)
c[i][j]=(c[i-][j]+c[i-][j-])%Mod;
f[][]=;
for (int i=;i<=n;i++)
for (int j=;j<=i;j++)
f[i][j]=((1LL*f[i-][j]*j)%Mod+f[i-][j-])%Mod;
for (int i=;i<n;i++)
for (int j=;j<=i;j++)
ans=(ans+f[i][j]*c[n][i])%Mod;
printf("%lld\n",ans);
return ;
}

Codeforces 568B Symmetric and Transitive的更多相关文章

  1. codeforces 569D D. Symmetric and Transitive(bell数+dp)

    题目链接: D. Symmetric and Transitive time limit per test 1.5 seconds memory limit per test 256 megabyte ...

  2. CodeForces 568B DP Symmetric and Transitive

    题意: 根据离散数学的内容知道,一个二元关系是一个二元有序组<x, y>的集合. 然后有一些特殊的二元关系,比如等价关系,满足三个条件: 自反性,任意的x,都有二元关系<x, x&g ...

  3. codeforces315Div1 B Symmetric and Transitive

    http://codeforces.com/contest/568/problem/B 题意就是给一个有n个元素的集合,现在需要求有多少个A的二元关系p,使得p是对称的,是传递的,但不是自反的. 首先 ...

  4. Codeforces Round #315 (Div. 2) (ABCD题解)

    比赛链接:http://codeforces.com/contest/569 A. Music time limit per test:2 seconds memory limit per test: ...

  5. 数学用语中的 透明 transitive property

    1.透明 https://en.wikipedia.org/wiki/Equivalence_relation In mathematics, an equivalence relation is a ...

  6. How to implement equals() and hashCode() methods in Java[reproduced]

    Part I:equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and ...

  7. Discrete.Differential.Geometry-An.Applied.Introduction(sig2008)笔记

    -------------------------------------------------------------- Chapter 1: Introduction to Discrete D ...

  8. override equals in Java

    equals() (javadoc) must define an equality relation (it must be reflexive, symmetric, and transitive ...

  9. Java的Object对象

    Object对象是除了基础对象之外,所有的对象都需要继承的父对象,包括数组也继承了Object Object里面的关键函数罗列如下: clone();调用该函数需要实现 Cloneable,否则会抛出 ...

随机推荐

  1. head,tail,cat,more,less

    tail FILE -n 4,查看文件最后4行内容head FILE -n 10,查看文件最前4行内容 使用cat more less都可以查看文本内容,但是它们三者有什么区别呢?more和less的 ...

  2. 百度搜索URL参数 搜索关键字

    http://www.baidu.com/s?wd=关键字 wd(Keyword):查询的关键词: http://www.baidu.com/s?wd=关键字&cl=3 cl(Class):搜 ...

  3. Codeforces Round #277.5 (Div. 2) --E. Hiking (01分数规划)

    http://codeforces.com/contest/489/problem/E E. Hiking time limit per test 1 second memory limit per ...

  4. 上海西服定制Angry Eagle 顶级西服,私人订制你的美

    上海西服定制Angry Eagle 顶级西服,私人订制你的美 上海西服定制Angry Eagle 顶级西服,私人订制你的美

  5. SOFTWARE_INTRODUCE_01

    &amp;amp;amp;amp;lt;br data-mce-bogus="1"&amp;amp;amp;amp;gt;&amp;amp;amp;amp; ...

  6. java-下载excel

    在java程序里面处理excel,我觉得比较方便的方式是先做出一个excel的模板(比如定义表头信息.表格名称等),然后根据这个模板往里面填充数据 我这里演示的是使用poi处理2007以上版本的exc ...

  7. USB HID Report Descriptor 报告描述符详解

    Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...

  8. Arcgis - Personal Geodatabase 和 File Geodatabase的区别.

     一.平台支持: 1.Personal Geodatabase:仅可在Windows 上运行: 2.File Geodatabase:跨平台支持,可在Windows 及UNIX.linux上运行. 评 ...

  9. Create new Android Virtual Device时不能创建

    在Create new Android Virtual Device时不能创建... 因为之前有重装过系统,ADT和java都没有更换,不知道是不是有哪里的环境(C盘中的配置)出错了... LOG在下 ...

  10. SQL2008转SQL2005数据库经验

    1.用SQL2008创建兼容2005的结构脚本. 2.在2005中生成数据库结构. 3.利用2005中的数据导入直接从源数据库中导入数据,此处注意自增长标识的选项需要添加,多表优化选项可以去掉,这里不 ...