cf 869c The Intriguing Obsession
题意:有三种三色的岛,用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的更多相关文章
- codeforces 869C The Intriguing Obsession【组合数学+dp+第二类斯特林公式】
C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces 869C The Intriguing Obsession
题意:有三种颜色的岛屿各a,b,c座,你可以在上面建桥.联通的点必须满足以下条件:1.颜色不同.2.颜色相同且联通的两个点之间的最短路径为3 其实之用考虑两种颜色的即可,状态转移方程也不难推出:F[i ...
- Codeforces 869C The Intriguing Obsession:组合数 or dp
题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. ...
- CodeForces - 869C The Intriguing Obsession(组合数)
题意:有三个集合,分别含有a.b.c个点,要求给这些点连线,也可以全都不连,每两点距离为1,在同一集合的两点最短距离至少为3的条件下,问有多少种连接方案. 分析: 1.先研究两个集合,若每两个集合都保 ...
- 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 ...
- The Intriguing Obsession
C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得: 1.由于题目中限制了两个相同 ...
- 【CF Round 439 C. The Intriguing Obsession】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 「日常训练」The Intriguing Obsession(CodeForces Round #439 Div.2 C)
2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要 ...
随机推荐
- python 处理geoJson to shp 互转
- IDEA分配内存无效
idea改启动内存分配, 改 C:/Users/xxx/.IntelliJIdea2018.1/confing/idea64.exe.vmoptions 或 C:/Users/xxx/.Intelli ...
- Vue绑定属性 绑定Class 绑定style
<template> <div id="app"> <h2>{{msg}}</h2> <br> <div v-bi ...
- ISO/IEC 9899:2011 条款6.7.8——类型定义
6.7.8 类型定义 语法 1.typedef-name: identifier 约束 2.一个typedef名指定了一个可变修改的类型,然后它应该具有语句块作用域. 语义 3.在一个声明中,该声明的 ...
- 重装Mac系统
首先介绍重装macos的一些重要事项: 重装系统之前需要弄清楚本机上安装的系统版本. 重装系统是需要管理员账户的. 获取系统镜像有多种方式,其中最常见的方式是从appstore中获取,但要注意的是要确 ...
- WPF 问题 PresentationCore.dll!System.Windows.Media.Composition.DUCE.Channel.SyncFlush() 分析
错误信息: 没有足够的内存继续执行程序 在 System.Windows.Media.Composition.DUCE.Channel.SyncFlush() 在 System.Windows.Int ...
- 查询数据,从链接地址中爬取文章内容jsoup
查询数据,从链接地址中爬取文章内容 protected void doGet(HttpServletRequest request, HttpServletResponse response) thr ...
- visual studio code跳转到定义处插件
visual studio code 中使用跳转到定义处的插件 https://marketplace.visualstudio.com/items?itemName=Shan.code-settin ...
- 【WebView】Android WebView中的Cookie操作
Hybrid App(混合式应用)的开发过程中少不了与WebView的交互,在涉及到账户体系的产品中,包含了一种登录状态的传递.比如,在Native(原生)界面的登录操作,进入到Web界面时,涉及到账 ...
- 123457123456#5#----com.MC.HuaHuaGame866----前拼后广--babyDrawGame-mc555
com.MC.HuaHuaGame866----前拼后广--babyDrawGame-mc