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. 学习java的第十二天

    一.今日收获(前两天家里有事,博客都忘了发了,唉) 1.通过看哔哩哔哩看黑马程序员的教学视频,学习了java中的数据类型自动转换.强制转换及注意事项三节 2.简单看了看完全学习手册 二.今日问题 1. ...

  2. .Net 下高性能分表分库组件-连接模式原理

    ShardingCore ShardingCore 一款ef-core下高性能.轻量级针对分表分库读写分离的解决方案,具有零依赖.零学习成本.零业务代码入侵. Github Source Code 助 ...

  3. 零基础学习java------day1------计算机基础以及java的一些简单了解

    一. java的简单了解 Java是一门面向对象编程语言,不仅吸收了C++的各种优点,还摒弃了C++里难以理解的多继承.指针等概念,因此Java语言具有功能强大和简单易用两个特征.Java语言作为静态 ...

  4. 移动开发之h5学习大纲

    移动开发学习形式:授课.自学 1.html5 css3 htm5shiv.js response.js 2.流式布局 自适应布局 盒模型 弹性盒模型 响应式布局3.iscroll swiper boo ...

  5. Ecshop 后台导出订单Excel时, 内存溢出的解决方法

    今天继续跟大家分享一下,在我配置Ecshop时的问题. 今天的问题是在后台想要导出订单列表Excel时出现的内存溢出.错误提示如下 问题:  Fatal error: Allowed memory s ...

  6. 编程之美Q1

    题目 和数书页有点类似,就直接数吧 #include<iostream> using namespace std; class q1 { public: size_t func(size_ ...

  7. Docker学习(六)——Dockerfile文件详解

    Docker学习(六)--Dockerfile文件详解 一.环境介绍 1.Dockerfile中所用的所有文件一定要和Dockerfile文件在同一级父目录下,可以为Dockerfile父目录的子目录 ...

  8. python做一个http接口测试框架

    目录结构 project case#测试用例 suite#测试目录 logs#测试日志 papi#测试类 result#测试结果 setting.py#配置文件 1.日志类,用于测试时日志记录 pya ...

  9. 使用Stream方式处理集合元素

    package com.itheima.demo03.Stream;import java.util.ArrayList;import java.util.stream.Stream;/** * @a ...

  10. ctypes与numpy.ctypeslib的使用

    numpy ctypeslib 与 ctypes接口使用说明 作者:elfin 目录 一.numpy.ctypeslib使用说明 1.1 准备好一个C++计算文件 1.2 ctypeslib主要的五个 ...