Basic DP

Problem URL:https://vjudge.net/problem/HDU-2018

Describe:

There is a cow that gives birth to a heifer every year.Every heifer starts in the fourth year and also has a heifer at the beginning of each year.Please program how many cows are in the nth year?

Input:

The input data consists of multiple test instances, one for each test instance, including an integer n (0 < n < 55), the meaning of n as described in the title.n=0 means the end of the input data, no processing.

Sample Input:

2
4
5
0

Samle Output

2
4
6
DP[] =
DP[] =
DP[] =
DP[] =
DP[i] = DP[i-] + DP[i-] i>=

AC code :

 #include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int DP[];
int main()
{
int n;
while(cin>>n && n!=)
{
DP[] = ;
DP[] = ;
DP[] = ;
DP[] = ;
for(int j = ;j < ;j++)
DP[j] = DP[j-] + DP[j-];
cout<<DP[n]<<endl;
}
return ;
}

HDU 2018 Cow Story DP的更多相关文章

  1. HDU 2018 DP

    A - 母牛的故事 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  2. HDU 1011 树形背包(DP) Starship Troopers

    题目链接:  HDU 1011 树形背包(DP) Starship Troopers 题意:  地图中有一些房间, 每个房间有一定的bugs和得到brains的可能性值, 一个人带领m支军队从入口(房 ...

  3. hdu 2296 aC自动机+dp(得到价值最大的字符串)

    Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. HDU 4778 状压DP

    一看就是状压,由于是类似博弈的游戏.游戏里的两人都是绝对聪明,那么先手的选择是能够确定最终局面的. 实际上是枚举最终局面情况,0代表是被Bob拿走的,1为Alice拿走的,当时Alice拿走且满足变换 ...

  5. HDOJ(HDU).3466 Dividing coins ( DP 01背包 无后效性的理解)

    HDOJ(HDU).3466 Dividing coins ( DP 01背包 无后效性的理解) 题意分析 要先排序,在做01背包,否则不满足无后效性,为什么呢? 等我理解了再补上. 代码总览 #in ...

  6. HDOJ(HDU).2546 饭卡(DP 01背包)

    HDOJ(HDU).2546 饭卡(DP 01背包) 题意分析 首先要对钱数小于5的时候特别处理,直接输出0.若钱数大于5,所有菜按价格排序,背包容量为钱数-5,对除去价格最贵的所有菜做01背包.因为 ...

  7. HDOJ(HDU).2602 Bone Collector (DP 01背包)

    HDOJ(HDU).2602 Bone Collector (DP 01背包) 题意分析 01背包的裸题 #include <iostream> #include <cstdio&g ...

  8. HDOJ(HDU).1058 Humble Numbers (DP)

    HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...

  9. HDOJ(HDU).1003 Max Sum (DP)

    HDOJ(HDU).1003 Max Sum (DP) 点我挑战题目 算法学习-–动态规划初探 题意分析 给出一段数字序列,求出最大连续子段和.典型的动态规划问题. 用数组a表示存储的数字序列,sum ...

随机推荐

  1. Jmeter(十一)函数助手

    可以在JMeter的选项菜单中找到函数助手对话框 我们可以从下拉列表中选择一个函数,并为其参数设定值.如图,表格的左边一列是函数参数的简要描述,右边一列是供用户填充参数的值.不同函数要求的参数也不同. ...

  2. Java集合框架之LinkedHashSet

    简述 LinkedHashSet底层使用 LinkedHashMap 来保存所有元素,它继承自 HashSet,其所有的方法操作上又与 HashSet 相同,因此 LinkedHashSet 的实现上 ...

  3. CodeForces 754D Fedor and coupons ——(k段线段最大交集)

    还记得lyf说过k=2的方法,但是推广到k是其他的话有点麻烦.现在这里采取另外一种方法. 先将所有线段按照L进行排序,然后优先队列保存R的值,然后每次用最小的R值,和当前的L来维护答案即可.同时,如果 ...

  4. 应用程序无法正常启动(0xc000007b)请单击确定关闭程序

    1.问题 在win10 VS2105 环境下面开发了一个调用get接口获取数据然后写入pg数据库的程序,在自己电脑上运行正常.复制到win7环境下运行,单击出现如下图所示的提示框. 2.原因分析 出现 ...

  5. TCP输出 之 tcp_write_xmit

    概述 tcp_write_xmit函数完成对待发送数据的分段发送,过程中会遍历发送队列,进行窗口检查,需要TSO分段则分段,然后调用tcp_transmit_skb发送数据段: 源码分析 static ...

  6. State Threads之Co-routine的调度

    1. 相关结构体 1.1 _st_epoll_data static struct _st_epolldata { _epoll_fd_data_t *fd_data; /* 调用 epoll_wai ...

  7. PHP AJAX返回 "TEXT"

    例子:通过AJAX间接访问数据库,查出Nation表显示在页面上,并添加删除按钮 //首先在外层添加一个按钮,并造好表头 <div><input type="button& ...

  8. golang 性能剖析pprof

    作为一个golang coder,使用golang编写代码是基本的要求. 能够写出代码,并能够熟悉程序执行过程中各方面的性能指标,则是更上一层楼. 如果在程序出现性能问题的时候,可以快速定位和解决问题 ...

  9. GDAL OGR Tools

    OGR2OGR ogr2ogr 使用文档 1. GeoJSON 转换 ShapeFile ogr2ogr -nlt POLYGON -skipfailures ground.shp ground.js ...

  10. 数据库开源框架之sqlcipher加密数据库

    访问github链接:https://github.com/sqlcipher/android-database-sqlcipher 访问 http://sqlcipher.net/sqlcipher ...