题意:有三种三色的岛,用a,b,c来标识这三种岛。然后规定,同种颜色的岛不能相连,而且同种颜色的岛不能和同一个其他颜色的岛相连。问有多少种建桥的方法。

题解:em....dp。我们先看两个岛之间怎么个连法。由题意可得岛与岛之间的链接是单射,我们定义f[a][b],表示有a个颜色1的岛和b个颜色2的岛想连的方案数。

首先当a==1 || b==1的时候 f[a][b]=(b+1)或者 (a+1)。然后尝试去找状态转移方程,我们对一个岛去连接另一个岛只有连或者不连两种状态,那么对于不连的状态为f[a-1][b];连的状态为b*f[a-1][b-1],这里要乘上一个b,因为有b个岛可连。

ac代码:

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define mt(a) memset(a,0,sizeof(a))
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod=;
ll f[][];
int main()
{
ll a,b,c;
cin>>a>>b>>c;
int mx=max(a,max(b,c));
mt(f);
for(int i=;i<=mx;i++)
{
f[i][]=i+;
f[][i]=i+;
}
for(int i=;i<=mx;i++)
{
for(int j=;j<=mx;j++)
{
f[i][j]=(j*f[i-][j-]+f[i-][j])%mod;
}
}
ll ans=;
ans=(ans*f[a][b])%mod;
ans=(ans*f[a][c])%mod;
ans=(ans*f[b][c])%mod;
cout<<ans<<endl;
return ;
}

cf 869c The Intriguing Obsession的更多相关文章

  1. codeforces 869C The Intriguing Obsession【组合数学+dp+第二类斯特林公式】

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. Codeforces 869C The Intriguing Obsession

    题意:有三种颜色的岛屿各a,b,c座,你可以在上面建桥.联通的点必须满足以下条件:1.颜色不同.2.颜色相同且联通的两个点之间的最短路径为3 其实之用考虑两种颜色的即可,状态转移方程也不难推出:F[i ...

  3. Codeforces 869C The Intriguing Obsession:组合数 or dp

    题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. ...

  4. CodeForces - 869C The Intriguing Obsession(组合数)

    题意:有三个集合,分别含有a.b.c个点,要求给这些点连线,也可以全都不连,每两点距离为1,在同一集合的两点最短距离至少为3的条件下,问有多少种连接方案. 分析: 1.先研究两个集合,若每两个集合都保 ...

  5. code forces 439 C. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  7. Codeforces Round #439 (Div. 2) C. The Intriguing Obsession

    C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得:     1.由于题目中限制了两个相同 ...

  8. 【CF Round 439 C. The Intriguing Obsession】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  9. 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)

    2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...

随机推荐

  1. linux网卡参数NM_CONTROLLED【转】

    安装操作系统时,自动生成的网卡配置文件,/etc/sysconfig/network-scripts/ifcfg-eth0里面有如下的参数:NM_CONTROLLED=yes说明 Network ma ...

  2. vsnprintf和snprintf(vsnprintf就是为了支持va_list,实现对于sprint功能封装而做的)

    vsnprintf和snprintf是C语言printf家族函数的成员,相关函数列表如下: #include <stdio.h> int printf(const char *format ...

  3. Android studio: Android Studio 3.5格式化布局代码时错乱

    Android studio 又来搞事情了,更新到3.5版本后,格式化布局文件代码时,布局文件代码竟然会发生变化,意思是不让格式化代码了呗? 垃圾的IDE. 解决办法: “File”-"Se ...

  4. FineReport 交叉报表

    交叉报表 - FineReport报表官网http://www.finereport.com/knowledge/professional/crossreport.html FineReport--- ...

  5. (转)darknet 训练心得

    1. 安装darknet 使用Git克隆源码 git clone https://github.com/pjreddie/darknet 我们可能需要修改Makefile,主要修改前三行,配置使用GP ...

  6. PHP使用MongoDB类操作MongoDB数据库总结

    参考:https://www.php.net/manual/zh/class.mongodb-driver-manager.php 参考:https://www.zhaokeli.com/articl ...

  7. typeScript模块<一>

    /*模块 模块的的概念 模块导出的几种方法 1.export 导出声明 2.export 导出语句 3.export default 4.import导入模块 模块化封装上一讲的DB库 */ /* 模 ...

  8. 圣诞节雪花效果,pc端

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. VPB测试 使用Osgdem运行例子

    1.Osgdem运行例子所需数据下载地址: http://www.cc.gatech.edu/projects/large_models/ps.html Download Elevation Map: ...

  10. ES6深入浅出-8 新版的类(下集)-2.全部语法

    解答提问 两边都没有构造函数的情况 父类没有构造函数,子类有构造函数的情况 下面用到的了this.body这个属性,所以super()必须要放在这行代码的上面. 在调用this之前必须调用super( ...