Codeforces 568B Symmetric and Transitive
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的更多相关文章
- 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 ...
- CodeForces 568B DP Symmetric and Transitive
题意: 根据离散数学的内容知道,一个二元关系是一个二元有序组<x, y>的集合. 然后有一些特殊的二元关系,比如等价关系,满足三个条件: 自反性,任意的x,都有二元关系<x, x&g ...
- codeforces315Div1 B Symmetric and Transitive
http://codeforces.com/contest/568/problem/B 题意就是给一个有n个元素的集合,现在需要求有多少个A的二元关系p,使得p是对称的,是传递的,但不是自反的. 首先 ...
- Codeforces Round #315 (Div. 2) (ABCD题解)
比赛链接:http://codeforces.com/contest/569 A. Music time limit per test:2 seconds memory limit per test: ...
- 数学用语中的 透明 transitive property
1.透明 https://en.wikipedia.org/wiki/Equivalence_relation In mathematics, an equivalence relation is a ...
- 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 ...
- Discrete.Differential.Geometry-An.Applied.Introduction(sig2008)笔记
-------------------------------------------------------------- Chapter 1: Introduction to Discrete D ...
- override equals in Java
equals() (javadoc) must define an equality relation (it must be reflexive, symmetric, and transitive ...
- Java的Object对象
Object对象是除了基础对象之外,所有的对象都需要继承的父对象,包括数组也继承了Object Object里面的关键函数罗列如下: clone();调用该函数需要实现 Cloneable,否则会抛出 ...
随机推荐
- HDOJ 1334 Perfect Cubes(暴力)
Problem Description For hundreds of years Fermat's Last Theorem, which stated simply that for n > ...
- 使用nvm来管理nodejs版本
nvm 是 Mac 下的 node 管理工具,有点类似管理 Ruby 的 rvm,如果是需要管理 Windows 下的 node,官方推荐是使用 nvmw 或 nvm-windows .nvm主要用来 ...
- svn出现“Previous operation has not finished; run 'cleanup' if it was interrupted”,解决方法
1.首先不需要动svn的服务器端.2.在客户端安装svn的客户端工具,自定义工具中为:command line client tools 安装完之后,在本地目录有svn.exe执行程序3.然后c ...
- Android系统如何实现UI的自适应
做Android应用的人都知道,要一个apk适用多个不同的手机屏幕是很容易的,就是在项目的res文件夹下面有多套相关的资源文件.程序运行的时候,Android系统会根据当前设备的信息去加载不同文件夹下 ...
- Comprehensive learning path – Data Science in Python深入学习路径-使用python数据中学习
http://blog.csdn.net/pipisorry/article/details/44245575 关于怎么学习python,并将python用于数据科学.数据分析.机器学习中的一篇非常好 ...
- ios 基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果demo
demo功能:基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果. demo说明:基于Core Animation的粒子发射系统,粒子用CAEmitterCell来初始化. 粒子画在背景层 ...
- 解决svn状态图标不显示的办法
SVN是一款出色的代码版本控制工具,大部分开发者都在使用.由于前不久刚做了系统,所以要重装一下SVN,结果就出了问题,问题就是,不管是文件处于什么状态他的提示图标都不显示,这就太不给力了吧.通过搜寻, ...
- sys--system-sysdba-sysoper用户区别
当Oracle 数据库安装完毕后,系统会自动创建sys和system这两个帐户.1.sys :缺省密码为CHANGE_ON_INSTALL ,且被授予DBA角色system :缺省密码为MANAGER ...
- 小学生之KTV播放原理
第一步: 创建一个Song类 //歌曲名称 public string SongName { get; set; } //歌曲路劲 public string SongPath { get; set ...
- MacOS U盘安装
通过Mac上的App Store下载安装程序 插入U盘 启动终端 输入命令 sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/R ...