1114. Boxes

Time limit: 0.6 second
Memory limit: 64 MB
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 N, A and B separated by space.

Output

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

Sample

input output
2 1 1
9
Problem Source: First competition for selecting the Bulgarian IOI team.
思路:dp;
dp[n][i][j]表示放前n个盒子时,前n个盒子中的红球为i个,蓝球为j个的方案数,状态转移方程dp[n][i][j]=sum(dp[n-1][x][y])(x<=i&&y<=j);
 1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<queue>
6 using namespace std;
7 typedef unsigned long long LL;
8 LL dp[40][40][40];
9 int main(void)
10 {
11 int i,j,k;
12 int n,m;
13 while(scanf("%d %d %d",&k,&n,&m)!=EOF)
14 {
15 memset(dp,0,sizeof(dp));
16 int x,y,z;
17 dp[0][0][0]=1;
18 int xx;
19 int yy;
20 LL sum=0;
21 for(i=1; i<=k; i++)
22 {
23 for(x=0; x<=n; x++)
24 {
25 for(y=0; y<=m; y++)
26 {
27 for(xx=0; xx<=x; xx++)
28 {
29 for(yy=0; yy<=y; yy++)
30 {
31 dp[i][x][y]+=dp[i-1][xx][yy];
32 }
33 }
34 if(i==k)
35 sum+=dp[i][x][y];
36 }
37 }
38 }
39 printf("%llu\n",sum);
40 }
41 return 0;
42 }

1114. Boxes的更多相关文章

  1. Ural 1114 Boxes

    Boxes Time Limit: 600ms Memory Limit: 16384KB This problem will be judged on Ural. Original ID: 1114 ...

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

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

  3. Problem B Boxes in a Line

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

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

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

  5. 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 ...

  6. csuoj 1114: 平方根大搜索

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1114 1114: 平方根大搜索 Time Limit: 5 Sec  Memory Limit:  ...

  7. boxes

    boxes [英][bɒksɪz][美][bɑ:ksɪz] n.盒( box的名词复数 ); 一盒; 电视; 小亭; v.把…装入盒[箱,匣]中( box的第三人称单数 ); 拳击;   以上结果来自 ...

  8. Piggy-Bank(HDU 1114)背包的一些基本变形

    Piggy-Bank  HDU 1114 初始化的细节问题: 因为要求恰好装满!! 所以初始化要注意: 初始化时除了F[0]为0,其它F[1..V]均设为−∞. 又这个题目是求最小价值: 则就是初始化 ...

  9. Brute Force - B. Candy Boxes ( Codeforces Round #278 (Div. 2)

    B. Candy Boxes Problem's Link:   http://codeforces.com/contest/488/problem/B Mean: T题目意思很简单,不解释. ana ...

随机推荐

  1. Linux信号1

    信号(signal)是一种软中断,他提供了一种处理异步事件的方法,也是进程间唯一的异步通信方式.在Linux系统中,根据POSIX标准扩展以后的信号机制,不仅可以用来通知某进程发生了什么事件,还可以给 ...

  2. MyBatis(3):优化MyBatis配置文件

    一.连接数据库的配置单独放在一个properties文件中 1,创建一个database.properties driver=com.mysql.jdbc.Driver url=jdbc:mysql: ...

  3. 【JAVA】【JVM】内存结构

    虽然jvm帮我们做了内存管理的工作,但是我们仍需要了解jvm到底做了什么,下面我们就一起去看一看 jvm启动时进行一系列的工作,其中一项就是开辟一块运行时内存.而这一块内存中又分为了五大区域,分别用于 ...

  4. VueAPI 2 (生命周期钩子函数)

    所有的生命周期钩子自动绑定 this 上下文到实例中,因此你可以访问数据,对属性和方法进行运算.这意味着你不能使用箭头函数来定义一个生命周期方法. beforeCreate 在实例初始化之后,此时还不 ...

  5. vueAPI (data,props,methods,watch,computed,template,render)

    data Vue 实例的数据对象.Vue 将会递归将 data 的属性转换为 getter/setter,从而让 data 的属性能够响应数据变化.实例创建之后,可以通过vm.$data来访问原始数据 ...

  6. FindUserByPageServlet

    package com.hopetesting.web.servlet;import com.hopetesting.domain.PageBean;import com.hopetesting.do ...

  7. 南邮CTF-MISC-Remove Boyfriend

    Remove Boyfriend 打开wireshark,找到关键字部分Remove Boyfriend 在第五行 在此行右击 点击追踪流 选择TCP流,可以分析出流量的传输过程 通过上面的执行列表 ...

  8. 解决“该Jenkins实例似乎已离线”

    在jenkins/pluginManager/advanced最下面 把:https://updates.jenkins-ci.org/update-center.json 换成: 1.http:// ...

  9. 【简】题解 P5283 [十二省联考2019]异或粽子

    传送门:P5283 [十二省联考2019]异或粽子 题目大意: 给一个长度为n的数列,找到异或和为前k大的区间,并求出这些区间的异或和的代数和. QWQ: 考试时想到了前缀异或 想到了对每个数按二进制 ...

  10. BDD自动化测试框架cucumber(1): 最基本的demo

    BDD(Behavior Driven Development),行为驱动开发, 对应自动化测试框架,python有behave,java有cucumber, 这次记录cucumber+springb ...