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. Invalid file system control data detected

    今天在做mkdir操作时报错:Invalid file system control data detected.检查用户和权限没问题,再检查磁盘空间也没问题.最后在网上找到如下信息: [proble ...

  2. 【转】android:DDMS查看Threads--不错

    原文网址:http://www.cnblogs.com/mybkn/archive/2012/05/27/2520335.html 有时候程序运行出现死锁或者信号量卡死是很纠结的问题,单看代码很难分析 ...

  3. 2015第25周三iframe小结

    一个 HTML页面可以有一个或多个子框架,这些子框架以<iframe>来标记,用来显示一个独立的HTML页面.这里所讲的框架编程包括框架的自我控制以及框架之间的互相访问,例如从一个框架中引 ...

  4. SPOJ3267--D-query (主席树入门练习)

    题意:查找区间内不同数字的个数. 两种做法,一种是 树状数组离线,另一种就是主席树. 树状数组离线操作的链接 http://www.cnblogs.com/oneshot/p/4110415.html ...

  5. HDU-1078

    Problem Description FatMouse has stored some cheese in a city. The city can be considered as a squar ...

  6. BootStrap——模态框

    模态框(Modal)是BootStrap中很棒的一个插件.可以去BootStrap菜鸟驿站里面看看. 模态框(Modal)是覆盖在父窗体上的子窗体.通常,目的是显示来自一个单独的源的内容,可以在不离开 ...

  7. 创建Chromium WebUI接口

    转载自:http://www.chromium.org/developers/webui Chrome的WebUI是那种,在Chrome中输入 "chrome://xxxx"就能打 ...

  8. Android Game

    收起相关游戏 cytus 机械迷城 小小炼狱 deemo 神庙逃离 现代战争4零点行动 植物大战僵尸2中文版 时空幻境 无尽之剑3 超级救火队 迷你冲撞 大战僵尸鸟 侍魂2 flappy bird 混 ...

  9. MC, MCMC, Gibbs採样 原理&amp;实现(in R)

    本文用讲一下指定分布的随机抽样方法:MC(Monte Carlo), MC(Markov Chain), MCMC(Markov Chain Monte Carlo)的基本原理,并用R语言实现了几个样 ...

  10. tomcat端口号、日志、启停

    cd到tomcat目录下 1.[root@rusky bin]# ./shutdown.sh         关闭tomcat 2.[root@rusky bin]# ./startup.sh     ...