题目

题意:有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. Week1 Team Homework #1: Study the projects done by previous student groups

      我们研究了学长的项目:百度3D地图API的调用.下面是我们对该项目的一些看法: 优点: 界面清晰 各类之间调用及其他关系容易理清. 缺点: 前段html代码过于冗杂,很多(div)块间的层次关系不 ...

  2. OC内存管理 @property的增强

    涉及到内存管理,只读,多线程等很多功能时,setter和getter方法也就没那么简单了:当然@property依然强大,很好用: 1:内存管理相关参数: *:retain:  (如果是oc对象类型) ...

  3. ubuntu 12.04 搭建nginx + php + mysql +phpmyadmin

    1. 使用官方PPA安装 Nginx 最新版本,使用以下命令:sudo add-apt-repository ppa:nginx/stablesudo apt-get updatesudo apt-g ...

  4. Codeforces Round #347 (Div. 2) B. Rebus

    题目链接: http://codeforces.com/contest/664/problem/B 题意: 给你一个等式,把等式左边的问号用1到n(n为等式右边的数)的数填好,使得等式成立 题解: 贪 ...

  5. 【BZOJ】【1272】【BeiJingWC2008】Gate of Babylon

    组合数学+容斥原理 Orz zyf-zyf 多重集组合数0.0还带个数限制?  ——>  <组合数学>第6章  6.2带重复的组合 组合数还要模P 0.0? ——> Lucas ...

  6. 阿里云CentOS6.3 安装MongoDB教程

    安装说明 系统环境:Centos-6.3安装软件:mongodb-linux-x86_64-2.2.2.tgz下载地址:http://www.mongodb.org/downloads安装机器:192 ...

  7. POJ 2253 Frogger (求某两点之间所有路径中最大边的最小值)

    题意:有两只青蛙,a在第一个石头,b在第二个石头,a要到b那里去,每种a到b的路径中都有最大边,求所有这些最大边的最小值.思路:将所有边长存起来,排好序后,二分枚举答案. 时间复杂度比较高,344ms ...

  8. [C++]虚函数-同名访问

    首先来看一下派生类和基类成员同名事的处理规则: 派生类内定义了一个与基类同名的成员,该现象称为同名覆盖,此时,无论派生类内部成员函数还是派生类的对象访问同名成员,如果未加任何特殊标识,则访问派生类中重 ...

  9. Jquery+Jquery-easyui的倒计时

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. linux下获取时间差

    #include <sys/time.h> struct timeval tpstart,tpend;     float timeuse;     gettimeofday(&t ...