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 ...
随机推荐
- 微软职位内部推荐-Software Development Engineer II
微软近期Open的职位: Job Title:Software Development EngineerII Division: Server & Tools Business - Comme ...
- iPhone OS 开发 - 了解并解决代码签名问题
译者:Jestery 发表时间:2010-04-24浏览量:21082评论数:0挑错数:0 了解并解决代码签名问题 (为保持跟开发环境以及APPLE开发者社区网站结构对应,一些名词未作翻译) 绝大多数 ...
- Qt websocket协议的实现
handshake(握手) client请求: GET /chat HTTP/1.1 Host: server.example.com Upgrade: ...
- PVPGN 暗黑破坏神2 1.11b战网配置问题汇总
写了第一篇配置指南之后,很多人向我咨询有关战网搭建的问题.于是觉得很有必要把若干常见的问题,和常用的进阶配置汇总一下,以方便更多人. 1.游戏版本和PVPGN与D2GS版本的问题. PVPGN建议选择 ...
- sqlserver insert into select
Insert into [fenxi].[dbo].[analysisresult]( [dayofweek] ,[quarter] ,[reporttime] ,[type] ,[value]) s ...
- 2006: [NOI2010]超级钢琴 - BZOJ
Description小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的音乐. 这架超级钢琴可以弹奏出n个音符,编号为1至n.第i个音符的美妙度为 ...
- 2565: 最长双回文串 - BZOJ
Description 顺序和逆序读起来完全一样的串叫做回文串.比如acbca是回文串,而abc不是(abc的顺序为“abc”,逆序为“cba”,不相同). 输入长度为n的串S,求S的最长双回文子串T ...
- 3144:[HNOI2013]切糕 - BZOJ
题目描述 Description 经过千辛万苦小 A 得到了一块切糕,切糕的形状是长方体,小 A 打算拦腰将切糕切成两半分给小 B.出于美观考虑,小 A 希望切面能尽量光滑且和谐.于是她找到你,希望你 ...
- Ignore files which are already versioned
If you accidentally added some files which should have been ignored, how do you get them out of vers ...
- 如何使用工具进行线上 PHP 性能追踪及分析?
工作了一两年的 PHPer 大概都多多少少知道一些性能分析的工具,比如 Xdebug.xhprof.New Relic .OneAPM.使用基于 Xdebug 进行 PHP 的性能分析,对于本地开发环 ...