题目

题意:有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. Css compatibility

    http://meiert.com/en/indices/css-properties/ http://www.standardista.com/css3/css3-selector-browser- ...

  2. Using self-defined Parcelable objects during an Android AIDL RPC / IPC call

    Using self-defined Parcelable objects during an Android AIDL RPC / IPC call In my previous post “Usi ...

  3. Qt websocket协议的实现

      handshake(握手) client请求:      GET /chat HTTP/1.1         Host: server.example.com         Upgrade: ...

  4. Xcode8兼容iOS7手记-b

    对于Xcode8的发布,苹果也是来了个大的跳跃,默认最低支持的iOS版本为8.0,当然也并不是说8.0以下就直接放弃了,虽然表现出来的是这样,毕竟使用8.0以下系统的还是大有人在的,老项目要兼容iOS ...

  5. java集合类(六)About Queue

    接上篇“java集合类(五)About Map” 终于来到了java集合类的尾声,太兴奋了,不是因为可以休息一阵了,而是因为又到了开启新知识的时刻,大家一起加油打气!!Come on...Fighti ...

  6. Oppotunity land---China

    China is a land of opportunity.Following the development of China,every sector has made their contri ...

  7. C#WinForm中播放背景音乐(亲测可用)

    using System.Runtime.InteropServices; public static uint SND_ASYNC = 0x0001; public static uint SND_ ...

  8. PythonChallenge 1:恺撒密码的解码

    题目: 解题思路:根据图中的K→M,O→Q,E→G,我们可以发现K,O,E这三个字母都向后移动了2位.据说恺撒率先使用了这一加密方法,因此将其命名为恺撒密码.它的基本思想是:通过把字母移动一定的位数来 ...

  9. c++ 继承多个类 及虚函数

    #include <iostream>using namespace std; class BaseA {public:    virtual void say() {        co ...

  10. ?--Porg.springframework.beans.MethodInvocationException: Property 'username' threw exception; nested exception is java.lang.NullPointerException

    使用BoneCP作为连接池,在启动Tomcat报出以下异常: 一月 02, 2016 2:12:17 下午 org.apache.tomcat.util.digester.SetPropertiesR ...