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})\),求不大于 ...
 
随机推荐
- C# 实现脚本辅助功能
			
http://blog.csdn.net/w86440044/article/details/42493683 http://blog.csdn.net/wujizhishang/article/de ...
 - 关于oraclize使用最好的一篇文章
			
https://medium.com/@msolomon44/using-apis-in-your-ethereum-smart-contract-with-oraclize-95656434292e ...
 - 黑盒测试实践-任务进度-Day05
			
任务进度11-30 使用工具 selenium 小组成员 华同学.郭同学.穆同学.沈同学.覃同学.刘同学 任务进度 经过了前两天的学习任务的安排,以下是大家的任务进度: 华同学(任务1) 1.由于昨天 ...
 - 1118 Lining Up
			
题目链接: http://poj.org/problem?id=1118 题意: 给定n个点, 求在同一直线上的点最多的直线上点的数目. 解法: 简单题目, 规模比较小, 暴力搜索. #includ ...
 - C++ generic tools -- from C++ Standard Library
			
今晚学了一下C++标准程序库, 来简单回顾和总结一下. 1.pair 结构体 // defined in <utility> , in the std namespace namespac ...
 - Qt资源整理ING
			
QCustomPlot:图表库,开源, 链接地址http://www.qcustomplot.com/index.php/download 一些Qt的开发库:http://qt-project.org ...
 - java grpc实例分析
			
一.Protocol Buffer 我们还是先给出一个在实际开发中经常会遇到的系统场景.比如:我们的客户端程序是使用Java开发的,可能运行自不同的平台,如:Linux.Windows或者是Andro ...
 - CodeForces 877E Danil and a Part-time Job(dfs序+线段树)
			
Danil decided to earn some money, so he had found a part-time job. The interview have went well, so ...
 - VMware安装Ubuntu分辨率无法适应屏幕的解决方法
			
 一开始虚拟机安装Ubuntu的时候遇到分辨率无法适应屏幕的时候,百度了一大堆都说使用xrandr命令来修改分辨率,但是还是无法适应1920x1080的屏幕,强迫症表示非常难受!  然后在不知道是 ...
 - 一些linux工具在windows版本下的文件放置位置
			
首先说明一下windows下的常用变量(这里是XP的,win7及以上的C:\Documents and Settings实际为C:\Users) %SystemDrive% 操作系统所在 ...