Aizu-1378- ICPC Asia 2017-Secret of Chocolate Poles
Secret of Chocolate Poles
Time Limit : 1 sec, Memory Limit : 262144 KB
Problem A Secret of Chocolate Poles
Wendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin disks, and dark thick disks. The thin disks are 1 cm thick, and the thick disks are k cm thick. Disks will be piled in glass cylinders.
Each pole should satisfy the following conditions for her secret mission, which we cannot tell.
- A pole should consist of at least one disk.
- The total thickness of disks in a pole should be less than or equal to l cm.
- The top disk and the bottom disk of a pole should be dark.
- A disk directly upon a white disk should be dark and vice versa.
As examples, six side views of poles are drawn in Figure A.1. These are the only possible side views she can make when l=5 and k=3.

Figure A.1. Six chocolate poles corresponding to Sample Input 1
Your task is to count the number of distinct side views she can make for given l and k to help her accomplish her secret mission.
Input
The input consists of a single test case in the following format.
l k
Here, the maximum possible total thickness of disks in a pole is l cm, and the thickness of the thick disks is k cm. l and k are integers satisfying 1≤l≤100 and 2≤k≤10.
Output
Output the number of possible distinct patterns.
Sample Input 1
5 3
Sample Output 1
6
Sample Input 2
9 10
Sample Output 2
5
Sample Input 3
10 10
Sample Output 3
6
Sample Input 4
20 5
Sample Output 4
86
Sample Input 5
100 2
Sample Output 5
3626169232670
Source: ACM International Collegiate Programming Contest , Asia Regional Tsukuba, Tsukuba, Japan, 2017-12-17
http://icpc.iisf.or.jp/2017-tsukuba/
题意:有三种盘子,1 cm厚的黑盘,1 cm厚的白盘,和 k cm厚的黑盘,最上面和最下面一定是黑盘,同颜色的盘子不能相邻,总厚度在 l cm 以内有多少种放法;
以黑盘个数做标记,忽略厚度不同,共有 (l+1)/ 2 种方法,每种再用厚盘替换普通黑盘,可以替换 1~ i 个,写个组合数就行了;
#include <iostream>
#include <cstring>
#include<cstdio>
using namespace std;
long long int c(long long m,long long n)
{
long long ans=1;
for(long long k=1; k<=n; k++)
{
ans=(ans*(m-n+k))/k;
}
return ans;
}
int main()
{
long long l, k;
while(cin >> l >> k)
{
long long i, j;
long long sum = 0;
for( i=1; i<=(l+1)/2; i++)
{
sum++;
for( j=1; j<=i; j++ )
{
if( i-j+k*j + i-1 > l) break;
sum += c(i,j);
}
}
printf("%lld\n",sum);
}
return 0;
}
Aizu-1378- ICPC Asia 2017-Secret of Chocolate Poles的更多相关文章
- Secret of Chocolate Poles (Aizu1378——dp)
Select Of Chocolate Poles 题意:有一个竖直放置的高度为l cm的盒子,现在有三种方块分别为1cm的白块,1cm的黑块,k cm的黑块,要求第一块放进去的必须是黑色的,盒子最上 ...
- Aizu - 1378 Secret of Chocolate Poles (DP)
你有三种盘子,黑薄,白薄,黑厚. 薄的盘子占1,厚的盘子占k. 有一个高度为L的桶,盘子总高度不能超出桶的总高度(可以小于等于).相同颜色的盘子不能挨着放. 问桶内装盘子的方案数. 如 L = 5,k ...
- 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
- 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online
Apple Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submi ...
- ICPC Asia Nanning 2017 I. Rake It In (DFS+贪心 或 对抗搜索+Alpha-Beta剪枝)
题目链接:Rake It In 比赛链接:ICPC Asia Nanning 2017 Description The designers have come up with a new simple ...
- ICPC Asia Nanning 2017 L. Twice Equation (规律 高精度运算)
题目链接:Twice Equation 比赛链接:ICPC Asia Nanning 2017 Description For given \(L\), find the smallest \(n\) ...
- ICPC Asia Nanning 2017 F. The Chosen One (高精度运算)
题目链接:The Chosen One 比赛链接:ICPC Asia Nanning 2017 题意 \(t\) 组样例,每组给出一个整数 \(n(2\le n\le 10^{50})\),求不大于 ...
随机推荐
- Scrapy Test
(flappbird) luo@luo-ThinkPad-W540:~$ scrapy startproject myspider0315New Scrapy project 'myspider031 ...
- 76-Relatives-欧拉函数
http://poj.org/problem?id=2407 Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submissions ...
- LIS和LCS LCIS
首先介绍一下LIS和LCS的DP解法O(N^2) LCS:两个有序序列a和b,求他们公共子序列的最大长度 我们定义一个数组DP[i][j],表示的是a的前i项和b的前j项的最大公共子序列的长度,那么由 ...
- JVM内存模型以及堆分配参数
程序计数器: 存放下一条要运行的指令:每个线程都必须用一个独立的程序计数器,用于记录下一条要运行的指令.程序计数器是一块线程私有的内存空间. JAVA虚拟机栈: 线程私有的内存空间,它保存方法的局部变 ...
- 网站如何集成Facebook和Twitter第三方登录
最近公司要求做海外的第三方登录:目前只做了Facebook和Twitter;国内百度到的信息太少VPN FQ百度+Google了很久终于弄好了.但是做第三方登录基本上都有个特点就是引入必须的js,设置 ...
- 团体程序设计天梯赛L1-023 输出GPLT 2017-03-22 17:56 39人阅读 评论(0) 收藏
L1-023. 输出GPLT 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一个长度不超过10000的.仅由英文字母构成的 ...
- c3p0-数据库连接池原理
一直用c3p0很久了,但也没时间或没主动去研究过,直到最近频频在出现一些莫名其妙的问题,觉得还是有必要了解和研究一下. c3p0是什么 c3p0的出现,是为了大大提高应用程序和数据库之间访问效率的. ...
- SQL命令行修改数据库
增加列: alter table tableName add columnName varchar(30) 修改列类型:alter table tableName alter column colum ...
- .net core MVC接受来自自前端的GET和POST请求方法的区别
小伙伴们都知道,常用的http请求有两种方式,即GET方法和POST方法,很多刚入门的童鞋难免都会有一个误区,是不是GET是从服务器上获取数据,POST是向服务器传送数据? 我的理解是:不论是GET还 ...
- ref和out params
ref和out都对函数参数采用引用传递形式——不管是值类型参数还是引用类型参数,并且定义函数和调用函数时都必须显示生命该参数为 ref/out形式.两者都可以使函数传回多个结果. ref 类似于 PH ...