Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
来源:互联网 发布:网络机房装修标准 编辑:程序博客网 时间:2024/06/16 02:12
C. The Intriguing Obsession
题目链接http://codeforces.com/contest/869/problem/C
解题心得:
1、由于题目中限制了两个相同颜色的点之间长度至少为3,这样就只能两两不同颜色的点相互组合,再将三种组合情况的可能种数乘起来。
2、然后就是两个不同颜色的点怎么组合的问题,这就是一个记忆化搜索(DP),假如红色点和黄色点相互组合,这样一个红色点可以对应一个黄色点(dp[x][y] = dp[x-1][y-1]*y),或者对应0个黄色点(dp[x][y]=dp[x-1][y]),然后将三种组合情况乘起来。
#include<bits/stdc++.h>using namespace std;const int maxn = 5010;const int mod = 998244353;typedef long long ll;ll dp[maxn][maxn];ll solve(ll x,ll y){ if(dp[x][y] > 0) return dp[x][y]; if(x == 0 || y == 0) return dp[x][y] = 1; return dp[x][y] = (solve(x-1,y)+y*solve(x-1,y-1)%mod)%mod;//可以选择不连接+选择连接(一个点可以选择和y个点中的一个建立映射关系)}int main(){ ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); ll s[3]; s[0] = a,s[1] = b,s[2] = c; sort(s,s+3);//从点数目小的向点数目大的映射 ll temp1 = solve(s[0],s[1]); ll temp2 = solve(s[1],s[2]); ll temp3 = solve(s[0],s[2]); ll ans = (((temp1*temp2)%mod)*temp3)%mod;//三中可能性是同时存在的,直接乘起来 printf("%lld",ans); return 0;}
阅读全文
0 0
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession dp
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 数学
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession(dp)
- Codeforces Round #439 (Div. 2) 869 C. The Intriguing Obsession
- Codeforces Round #439 (Div. 2)-The Intriguing Obsession(DP)
- Codeforces 869C ( Codeforces Round #439 (Div. 2) ) The Intriguing Obsession 组合数学
- CF round#439 div.2 C The Intriguing Obsession【DP】
- Codeforces Round #439 (Div. 2) C 869C The Intriguing Obsession(思维+简单组合)
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession(组合数)
- Codeforces Round #439 (Div. 2) C The Intriguing Obsession (组合数学)
- Codeforces Round #439 (Div. 2)C. The Intriguing Obsession (组合数详解)
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession 组合数学
- Codeforces Round #439 (Div. 2) C.The Intriguing Obsession(组合数、记忆化搜索)
- Codeforces Round #439 C. The Intriguing Obsession (组合数)
- Codeforces Round #439 C The Intriguing Obsession(dp)
- Hibernate ORM 之 单向一对多
- 试试
- MYSQL自带工具使用介绍
- opencv学习笔记 一 图像读取与操作
- 机会是给有准备的人-为了进入牛B软件公司我需要------------------------
- Codeforces Round #439 (Div. 2) C. The Intriguing Obsession
- 数据结构实验二之顺序表
- Golang
- TCP粘包与拆包问题
- 亮眼的弹出框--SweetAlert2
- 小白做游戏的辛酸路程
- 多列等高布局
- Android保存图片到系统图库
- iOS app配置多环境变量和制作马甲包