题目

题意:有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)的更多相关文章

  1. leetcode_1048. Longest String Chain_[DP,动态规划,记忆化搜索]

    1048. Longest String Chain https://leetcode.com/problems/longest-string-chain/ Let's say word1 is a ...

  2. SDUT 1305 查找基因序列问题 dp

    题目: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1305 这个题就是一个类似公共子串的dp ...

  3. 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 ...

  4. HDU4681 String(dp)

    题目链接. #include <iostream> #include <cstdio> #include <cstring> #include <cstdli ...

  5. hdu 4055 Number String(dp)

    Problem Description The signature of a permutation is a string that is computed as follows: for each ...

  6. uav 11258 String Partition (DP)

    Problem F - String Partition                                                                         ...

  7. hdu3336 Count the string kmp+dp

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3336 很容易想到用kmp 这里是next数组的应用 定义dp[i]表示以s[i]结尾的前缀的总数 那么 ...

  8. hdu5707-Combine String(DP)

    Problem Description Given three strings a, b and c , your mission is to check whether c is the combi ...

  9. 10.Regular Expression Matching (String; Back-Track,DP)

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

随机推荐

  1. cocos2dx中加载图片资源的方法,和从内存中获取已经加载的图片资源的方法

    游戏中通常需要将常用的资源如:声音,图片,plist文件,提前加载进内存,以加快游戏的流畅度 1.预加载声音: SimpleAudioEngine::getInstance()->preload ...

  2. BitmapSource ConvertTo Bitmap

    偶遇需要把 BitmapSource 转成 Bitmap. .. using System; using System.Drawing; using System.Drawing.Imaging; u ...

  3. 清橙A1363. 水位 - 清华大学2012年信息学优秀高中学子夏令营

    问题描述 有一个正方形的地区,该地区特点鲜明:如果把它等分为N×N个小正方形格子的话,在每个格子内的任意地点的地表高度是相同的,并且是一个0到M之间的整数.正方形地区的外部被无限高的边界包围. 该地区 ...

  4. 1452: [JSOI2009]Count - BZOJ

    Description Input Output Sample Input Sample Output 1 2HINT 一开始还想什么离线做,其实不用,空间足够,我们直接开100个二维树状数组,然后就 ...

  5. hihocoder #1300 : 展胜地的鲤鱼旗 dp

    题目链接: http://hihocoder.com/problemset/problem/1300 题解: 先用栈预处理出每个‘)’匹配的‘(’的位子,放在pos数组中. dp[i]表示以i结尾的合 ...

  6. eclipse中加放js文件报js语法错误解决办法

    1) eclipse设置         window->preference-> JavaScript -> Validator->Errors/Warnings->E ...

  7. [bzoj 2159]Crash的文明世界

    今天看到一个鬼题 心情好的时候写 [题意]求树上所有点对距离的k次方和,所有边权为1 大爷方的题解:http://tonyfang.is-programmer.com/posts/204972.htm ...

  8. HtmlAgilityPack 简单运用

    WebClient client = new WebClient(); MemoryStream ms = new MemoryStream(client.DownloadData("htt ...

  9. hdoj 2204 Eddy's爱好

    原文链接:http://www.cnblogs.com/DrunBee/archive/2012/09/05/2672546.html 题意:给你一个正整数N,确定在1到N之间有多少个可以表示成M^K ...

  10. 【leetcode】Combination Sum (middle)

    Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...