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. AtCoder AGC019E Shuffle and Swap (DP、FFT、多项式求逆、多项式快速幂)

    题目链接 https://atcoder.jp/contests/agc019/tasks/agc019_e 题解 tourist的神仙E题啊做不来做不来--这题我好像想歪了啊= =-- 首先我们可以 ...

  2. Java线程之Timer

    简述 java.util.Timer是一个定时器,用来调度线程在某个时间执行.在初始化Timer时,开启一个线程循环提取TaskQueue任务数组中的任务, 如果任务数组为空,线程等待直到添加任务: ...

  3. 背景(background)

    背景(background) 背景家族由5个主要的背景属性组成 background-color背景颜色 background-color:colorNome(取值 如:颜色名 red green. ...

  4. [题解] [bzoj2622] 深入虎穴

    题解 题解 考虑到正着跑不好想, 我们尝试反向跑 以每个终点作为起点, 维护每个点的最小值和次小值(最小的被老虎ban掉了) 转移的时候用当前点的次小值去更新其所连的点的最小值和次小值 由于最小的次小 ...

  5. Spring Cloud Feign声明式服务调用(转载)+遇到的问题

    转载:原文 总结: 1.pom添加依赖 2.application中填写正确的eureka配置 3.启动项中增加注解 @EnableFeignClients 4.填写正确的调用接口 通过原文使用Fei ...

  6. IP输出 之 分片ip_fragment、ip_do_fragment

    概述 ip_fragment函数用于判断是否进行分片,在没有设置DF标记的情况下进入分片,如果设置了DF标记,则继续判断,如果不允许DF分片或者收到的最大分片大于MTU大小,则回复ICMP,释放skb ...

  7. 微信小程序之地址联动

    这就是我们要实现的效果 <view class="consignee"> <!-- consignee 收件人 --> <text>收件人: & ...

  8. Android studio 项目支持JNI方法

    步骤: 1. build.gradle 配置如下,主要两项 ndk 和 sourceSets apply plugin: 'com.android.application' android { com ...

  9. java和C++之间的调用

    java和C++之间的调用其实和C差不多,只是有几点不一样 区别: 包名.类名.h 这个头文件必须有且必须在JNI目录里 后缀不需要修改 /* DO NOT EDIT THIS FILE - it i ...

  10. MySQL如何查询某个字段长度最大的记录

    转: MySQL如何查询某个字段长度最大的记录 2017年06月24日 13:12:15 翔云123456 阅读数 18348   版权声明:本文为翔云原创文章,未经博主允许不得转载. https:/ ...