Boxes

Time Limit: 600ms
Memory Limit: 16384KB

This problem will be judged on Ural. Original ID: 1114
64-bit integer IO format: %lld      Java class name: (Any)

 
N boxes are lined up in a sequence (1 ≤ N ≤ 20). You have A red balls and B blue balls (0 ≤ A ≤ 15, 0 ≤ B ≤ 15). The red balls (and the blue ones) are exactly the same. You can place the balls in the boxes. It is allowed to put in a box, balls of the two kinds, or only from one kind. You can also leave some of the boxes empty. It's not necessary to place all the balls in the boxes. Write a program, which finds the number of different ways to place the balls in the boxes in the described way.
 

Input

Input contains one line with three integers NA and B separated by space.
 

Output

The result of your program must be an integer written on the only line of output.
 

Sample Input

2 1 1

Sample Output

9

Source

 
解题:强行dp
$dp[i][j][k]表示前i个盒子放了j个红球k个蓝球的方案数$
 #include <bits/stdc++.h>
using namespace std;
const int maxn = ;
unsigned long long dp[maxn][maxn][maxn];
int main() {
int N,A,B;
while(~scanf("%d%d%d",&N,&A,&B)) {
memset(dp,,sizeof dp);
dp[][][] = ;
for(int i = ; i <= N; ++i)
for(int j = ; j <= A; ++j)
for(int k = ; k <= B; ++k)
for(int a = ; a <= j; ++a)
for(int b = ; b <= k; ++b)
dp[i][j][k] += dp[i-][a][b];
unsigned long long ret = ;
for(int i = ; i <= A; ++i)
for(int j = ; j <= B; ++j)
ret += dp[N][i][j];
printf("%I64u\n",ret);
}
return ;
}

Ural 1114 Boxes的更多相关文章

  1. 1114. Boxes

    1114. Boxes Time limit: 0.6 secondMemory limit: 64 MB N boxes are lined up in a sequence (1 ≤ N ≤ 20 ...

  2. ural 1114,计数dp

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1114 题意:N个盒子,a个红球,b个蓝球,把求放到盒子中去,没有任何限制,有多少种放法. ...

  3. noi 666 放苹果

    题目链接:http://noi.openjudge.cn/ch0206/666/ 和ural 1114题意类似,但是有顺序,5,1,1和1,5,1是同一种序列.不能直接枚举 d(i,j) 前 i 个盘 ...

  4. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  5. URAL 1873. GOV Chronicles

    唔 神题一道 大家感受一下 1873. GOV Chronicles Time limit: 0.5 secondMemory limit: 64 MB A chilly autumn night. ...

  6. Fedora 24 Gnome Boxes 无法ping通网络

    安装Fedora 24在试用虚拟机时发现无法ping通外网. 我傻傻地以为是软件问题. 问题描述: 尝试ping程序来测试网络连通性: (我之前也是ping百度,后来在为了少打字百度了一些比较短的域名 ...

  7. Problem B Boxes in a Line

     省赛B题....手写链表..其实很简单的.... 比赛时太急了,各种手残....没搞出来....要不然就有金了...注:对相邻的元素需要特判..... Problem B Boxes in a Li ...

  8. hiho #1114 : 小Hi小Ho的惊天大作战:扫雷·一

    #1114 : 小Hi小Ho的惊天大作战:扫雷·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 故事背景:密室.监视器与充满危机的广场 “我们还是循序渐进,先来考虑这 ...

  9. Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes 树状数组s

    C. Inna and Candy Boxes   Inna loves sweets very much. She has n closed present boxes lines up in a ...

随机推荐

  1. 在sql语句中使用关键字

    背景 开发过程中遇到了遇到了一句sql语句一直报错,看了一下字段名和表名都对应上了,但是还是一直报错 sql语句如下: update table set using = ""hh ...

  2. gitlab&Jenkins 详细介绍及其应用

    第1章 gitlab 1.1 系统环境 [root@jenkins ~]# cat  /etc/redhat-release CentOS Linux release 7.2.1511 (Core) ...

  3. java HashMap和LinkedHashMap区别

    我们用的最多的是HashMap,在Map 中插入.删除和定位元素,HashMap 是最好的选择.但如果您要按自然顺序或自定义顺序遍历键,那么TreeMap会更好.如果需要输出的顺序和输入的相同,那么用 ...

  4. vue.js学习文档

    1.实例化vue对象 new Vue(){ } 2.对象属性 el: 控制的属性 data: 数据存储位置 methods: 方法存储位置 template: 模板样式 computed: 计算属性 ...

  5. 推荐一波 瀑布流的RecylceView

    推荐博客:http://www.bubuko.com/infodetail-999014.html

  6. PS如何批量整理图片大下

    https://jingyan.baidu.com/article/cdddd41cc7849853cb00e193.html

  7. myeclipse中js文件报错

    这几天在myeclipse中添加文件时,会报错,但是代码是从官网上下载的,没有错误,只是myeclipse的检查较为严格.在网上找到解决方案,希望可以帮到强迫症的人. 解决步骤: 1.window→P ...

  8. leetcode650 2 Keys Keyboard

    思路: 把给定的数分解质因子之后,对于每一个质因子x,都需要x次操作(一次copy all操作和x-1次paste),所以答案就是对分解后的所有质因子求和. 实现: class Solution { ...

  9. reduce的特殊用法

    //计算数组中每个元素出现的次数var arr = ["apple","orange","apple","orange" ...

  10. 可滚动的ResultSet类型 实现分页

    可滚动的ResultSet类型. 这个类型支持前后滚动取得纪录next().previous(),回到第一行first(),同时还支持要取的 ResultSet中的第几行 absolute(int n ...