1114. Boxes
1114. Boxes
Memory limit: 64 MB
≤ 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
Output
Sample
input | output |
---|---|
2 1 1 |
9 |
My submissions All submissions (8069) All accepted submissions (2464) Solutions rating (2022)
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的更多相关文章
- Ural 1114 Boxes
Boxes Time Limit: 600ms Memory Limit: 16384KB This problem will be judged on Ural. Original ID: 1114 ...
- Fedora 24 Gnome Boxes 无法ping通网络
安装Fedora 24在试用虚拟机时发现无法ping通外网. 我傻傻地以为是软件问题. 问题描述: 尝试ping程序来测试网络连通性: (我之前也是ping百度,后来在为了少打字百度了一些比较短的域名 ...
- Problem B Boxes in a Line
省赛B题....手写链表..其实很简单的.... 比赛时太急了,各种手残....没搞出来....要不然就有金了...注:对相邻的元素需要特判..... Problem B Boxes in a Li ...
- hiho #1114 : 小Hi小Ho的惊天大作战:扫雷·一
#1114 : 小Hi小Ho的惊天大作战:扫雷·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 故事背景:密室.监视器与充满危机的广场 “我们还是循序渐进,先来考虑这 ...
- 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 ...
- csuoj 1114: 平方根大搜索
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1114 1114: 平方根大搜索 Time Limit: 5 Sec Memory Limit: ...
- boxes
boxes [英][bɒksɪz][美][bɑ:ksɪz] n.盒( box的名词复数 ); 一盒; 电视; 小亭; v.把…装入盒[箱,匣]中( box的第三人称单数 ); 拳击; 以上结果来自 ...
- Piggy-Bank(HDU 1114)背包的一些基本变形
Piggy-Bank HDU 1114 初始化的细节问题: 因为要求恰好装满!! 所以初始化要注意: 初始化时除了F[0]为0,其它F[1..V]均设为−∞. 又这个题目是求最小价值: 则就是初始化 ...
- 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 ...
随机推荐
- 06 windows安装Python+Pycharm+Scrapy环境
windows安装Python+Pycharm+Scrapy环境 使用微信扫码关注微信公众号,并回复:"Python工具包",免费获取下载链接! 一.卸载python环境 卸载以下 ...
- 解决CentOS7 docker容器映射端口只监听ipv6的问题
问题现象 docker容器起来以后,查看9100端口监听情况,如下图: $ ss -lntp State Recv-Q Send-Q Local Address:Port Peer Address:P ...
- C语言中储存的大小端问题
一.大小端定义 研究变量的高低字节:从左往右看,字节序递增,也就是最右边是最低字节,最右边是最高字节.如 int i = 0x01020304, 01是高字节,04是低字节.如果是字符串如char a ...
- HDFS【Namenode、SecondaryNamenode、Datanode】
目录 一. NameNode和SecondaryNameNode 1.NN和2NN 工作机制 2. NN和2NN中的fsimage.edits分析 3.checkpoint设置 4.namenode故 ...
- 【原创】Altium生成Gerber时跳出The Film is too small for this PCB的解决办法
在用altium Designer画板子的时候,要生成gerber文件的时候,会出错,出现这样的提示框:"The Film is too small for this PCB" 原 ...
- Stream.toMap
Collectors类的tomap方法将流收集到映射实例中. list 转 map collection.stream().collect(Collectors.toMap(User::getId, ...
- SpringAOP浅析
1.问题 问题:想要添加日志记录.性能监控.安全监测 2.最初解决方案 2.1.最初解决方案 缺点:太多重复代码,且紧耦合 2.2.抽象类进行共性设计,子类进行个性设计,此处不讲解,缺点一荣俱荣,一损 ...
- 一、手把手教你docker搭建fastDFS文件上传下载服务器
在搭建fastDFS文件上传下载服务器之前,你需要准备的有一个可连接的linux服务器,并且该linux服务器上已经安装了docker,若还有没安装docker的,先百度自行安装docker. 1.执 ...
- Mysql 分页查询sql优化
先查下数据表的总条数: SELECT COUNT(id) FROM ts_translation_send_address 执行分页界SQL 查看使用时间2.210s SELECT * FROM ts ...
- 【C/C++】习题3-7 DNA/算法竞赛入门经典/数组与字符串
[题目] 输入m组n长的DNA序列,要求找出和其他Hamming距离最小的那个序列,求其与其他的Hamming距离总和. 如果有多个序列,求字典序最小的. [注]这道题是我理解错误,不是找出输入的序列 ...