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. 【WIP_S4】栈

    创建: 2018/01/15 更新: 2018/01/24 更改标题 [[WIP_S3]堆] => [[WIP_S4]堆] 继续添加内容 更新: 2018/05/13 更改标题  [[WIP_S ...

  2. vim 跳行查看日志

    VIM 跳跃行号 一.显示行号 在命令模式下输入 :set nu   或者   :set number 即可显示行号 二.跳跃行号 在编辑模式下输入 ngg 或者 nG [n为指定的行数(如25)] ...

  3. Ajax 知识点总结

    1.AJAX的优缺点都有什么? 最大的一点是页面无刷新,用户的体验非常好.使用异步方式与服务器通信,具有更加迅速的响应能力.可以把以前一些服务器负担的工作转嫁到客户端,利用客户端闲置的能力来处理,减轻 ...

  4. python程序展现图片遇到的坑

    使用cv2展示图片的时候遇到了问题,提示:TypeError: Required argument 'mat' (pos 2) not found 给定的图片路径是没得问题的,代码如下: 使用open ...

  5. 编写UI自动化测试用例原则

    1.一个脚本是一个完整的场景,从用户登陆操作到用户退出系统关闭浏览器.2.一个脚本脚本只验证一个功能点,不要试图用户登陆系统后把所有的功能都进行验证再退出系统3.尽量只做功能中正向逻辑的验证,不要考虑 ...

  6. Oracle数据库数据显示乱码问题解决方法。

    一.问题描述:       在将其它数据库的数据导出文件导入本地新建数据库时,所导入的数据全部是乱码,一般表现为数据表中列的值类似于"?????",即内容大部分为?的表现形式.初步 ...

  7. [ CodeForces 515 D ] Drazil and Tiles

    \(\\\) \(Description\) 给出一个\(N\times M\) 的网格,一些位置是障碍,其他位置是空地,求是否存在一个用 \(1\times 2\)的骨牌铺满空地的方案,以及方案是否 ...

  8. Android 解决RecyclerView瀑布流效果结合Glide使用时图片变形的问题

    问题描述:使用Glide加载RecyclerView的Item中的图片,RecyclerView使用了瀑布流展示图片,但是滚动时图片会不断的加载,并且大小位置都会改变,造成显示错乱. 解决方法:使用瀑 ...

  9. opencv边缘滤波

    2018-03-0422:16:11 import cv2 as cv import numpy as np def bi_demo (image): print ("ceshi" ...

  10. Python学习日记之练习代码

    # -*- coding:utf-8 -*- number = 23 test=True while test: guess=int(raw_input('输入数字')) if guess==numb ...