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. bzoj 1800: [Ahoi2009]fly 飞行棋【枚举】

    在圆里所以没有平行四边形,n^4枚举点即可 #include<iostream> #include<cstdio> using namespace std; const int ...

  2. 引水入城 2010年NOIP全国联赛提高组(bfs+贪心)

    1066 引水入城 2010年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 在一个遥远 ...

  3. http升级https(转)

    让你的网站免费支持 HTTPS 及 Nginx 平滑升级 为什么要使用 HTTPS ? 首先来说一下 HTTP 与 HTTPS 协议的区别吧,他们的根本区别就是 HTTPS 在 HTTP 协议的基础上 ...

  4. spring 嵌套事务问题

    嵌套事物总结 事物成功总结 1.内外都无try Catch的时候,外部异常,全部回滚. 2.内外都无try Catch的时候,内部异常,全部回滚. 3.外部有try Catch时候,内部异常,全部回滚 ...

  5. [转]C语言常见错误总结1

    指针与数组的对比c程序中,指针和数组在不少地方可以相互替换着用,让人产生一种错觉,以为两者是等价的 数组要么在静态存储区被创建(如全局数组),要么在栈上被创建.数组名对应着(而不是指向)一块内存,其地 ...

  6. Android 性能优化(23)*性能工具之「Heap Viewer, Memory Monitor, Allocation Tracker」Memory Profilers

    Memory Profilers In this document Memory Monitor Heap Viewer Allocation Tracker You should also read ...

  7. 283 Move Zeroes 移动零

    给定一个数组 nums, 编写一个函数将所有 0 移动到它的末尾,同时保持非零元素的相对顺序.例如, 定义 nums = [0, 1, 0, 3, 12],调用函数之后, nums 应为 [1, 3, ...

  8. SVN服务器搭建 内网可用外网不可用的问题

    检查1:内网端口映射到了外网端口,这样外网才能够访问到 映射的方式有两种: 1.通过路由器的虚拟服务器功能,网上一搜一大把. 2.将路由器的DMZ功能开启,并把DMZ主机设置为目标计算机. 检查2:S ...

  9. [ CodeForces 1065 B ] Vasya and Isolated Vertices

    \(\\\) \(Description\) 求一个\(N\)个点\(M\)条边的无向图,点度为 \(0\) 的点最多和最少的数量. \(N\le 10^5,M\le \frac {N\times ( ...

  10. ValueError: multi-byte encodings are not supported

    pyton解析xml时,报错 是因为编码的问题,把xml的头 <?xml version="1.0" encoding="gb2312"?> 改成 ...