sdut 2840 Best string Orz~ (dp)
题意:有n1个o, n2个r, n3个z, n4个~, 求有多少种组合使 组合出来的字符串的任意前缀都满足 o的个数>=r的个数,
r的个数>=z的个数 ……………………
思路:递推,枚举用四重循环控制orz~的个数符合题意, 然后当前个数的orz~等于之前orz~分别少一个推过来的,所以相加上,
注意之前可能orz~的某一个没有。
下面的代码是看了标程之后写出来的。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL long long int main()
{
int n1, n2, n3, n4;
int i1, i2, i3, i4;
LL d[][][][];
d[][][][] = ;
for(i1 = ; i1 < ; i1++)
for(i2 = ; i2 <= i1; i2++)
for(i3 = ; i3 <= i2; i3++)
for(i4 = ; i4 <= i3; i4++)
{
if(i1) d[i1][i2][i3][i4] += d[i1-][i2][i3][i4];
if(i2) d[i1][i2][i3][i4] += d[i1][i2-][i3][i4];
if(i3) d[i1][i2][i3][i4] += d[i1][i2][i3-][i4];
if(i4) d[i1][i2][i3][i4] += d[i1][i2][i3][i4-];
}
while(cin>>n1>>n2>>n3>>n4)
{
if(n1==&&n2==&&n3==&&n4==) break;
cout<<d[n1][n2][n3][n4]<<endl;
}
return ;
}
sdut 2840 Best string Orz~ (dp)的更多相关文章
- leetcode_1048. Longest String Chain_[DP,动态规划,记忆化搜索]
1048. Longest String Chain https://leetcode.com/problems/longest-string-chain/ Let's say word1 is a ...
- SDUT 1305 查找基因序列问题 dp
题目: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1305 这个题就是一个类似公共子串的dp ...
- hdu 3336 Count the string KMP+DP优化
Count the string Problem Description It is well known that AekdyCoin is good at string problems as w ...
- HDU4681 String(dp)
题目链接. #include <iostream> #include <cstdio> #include <cstring> #include <cstdli ...
- hdu 4055 Number String(dp)
Problem Description The signature of a permutation is a string that is computed as follows: for each ...
- uav 11258 String Partition (DP)
Problem F - String Partition ...
- hdu3336 Count the string kmp+dp
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3336 很容易想到用kmp 这里是next数组的应用 定义dp[i]表示以s[i]结尾的前缀的总数 那么 ...
- hdu5707-Combine String(DP)
Problem Description Given three strings a, b and c , your mission is to check whether c is the combi ...
- 10.Regular Expression Matching (String; Back-Track,DP)
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
随机推荐
- github pages
http://zyip.github.io/facemaker/index echo "hello world" >>hello.htm git init git ad ...
- ifame 跨域高度自适应
代码如下:var iframeids = ['memberIndexIframe','inquiryCenterIframe','everychinaBbsIframe']; var iframehi ...
- Eclipse插件安装总结
Eclipse的插件安装分为在线安装和离线安装两类: 1.在线安装(新版本的推荐方式) 最常用和最好用的方式,直接使用Eclipse的Ecliplse Marketplace,搜索你需要的插件,然后点 ...
- 【模板】Big-Step-Giant-Step 大步小步
求一个 的最小整数解 bsgs 当h是质数的时候使用 extbsgs 不满足上面那种情况的时候 具体参见http://tonyfang.is-programmer.com/posts/178997.h ...
- 解决Navicat Error: Missing required libmysql_d.dll
在Navicat(H:\Program Files (x86)\Navicat for MySQL)目录下找到libmysql_d.dll,复制到C盘:system/wow64文件夹下. 重新打开na ...
- cf 359C
stl 里的map使用 然后就是快速幂取余 #include <cstdio> #include <cstring> #include <algorithm> ...
- 关于prototype以及继承方面的理解
学习笔记(致 渐悟) 写在前面的话 今天看<javascript高级程序设计>的时候,看到有关继承和原型链prototype时遇到些疑问,特回来研究下,同时也感谢JS群网友"渐悟 ...
- hdu 1755 A Number Puzzle
这题枚举k节省时间 ;}
- kindeditor.net应用
1.网址:http://kindeditor.net/docs/usage.html
- codeforces D
D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes in ...