poj-2229
来源:互联网 发布:网络系统集成基础 编辑:程序博客网 时间:2024/05/17 08:57
DP问题
状态转移方程:如果i%2!=0
dp[i]=dp[i-1]
否则
dp[i]=dp[i-1]+dp[i/2]
#include <iostream>#include <stdio.h>#include <math.h>#include <algorithm>#include <string.h>#include <string>#include <sstream>#include <stdlib.h>#include <malloc.h>using namespace std;int dp[1000010];int main (){ dp[1]=1; dp[2]=2; for (int i=3;i<=1000002;i++) { if (i%2 != 0) dp[i]=dp[i-1]; else { dp[i]=dp[i-1]+dp[i/2]; dp[i]=dp[i]%1000000000; } } int n; while (cin>>n) { cout<<dp[n]<<endl; } return 0;}
0 0
- poj 2229
- POJ-2229
- poj 2229
- poj----2229
- poj-2229
- POJ - 2229
- poj 2229
- poj 2229
- poj--2229
- poj 2229
- poj 2229
- poj 2229
- poj 2229
- POJ 2229
- POJ 2229 Sumsets
- poj 2229 Sumsets
- [POJ] 2229 Sumsets
- poj 2229 dp
- pagefile.sys文件删除及移动方法
- C++简单工厂模式-Static Factory Method
- NYOJ 1009 So Easy[Ⅰ]【简单题】
- Http协议基础
- Matlab 几种卷积的实现与比较(conv与filter,conv2与filter2)
- poj-2229
- PHP+MySQL导出Excel的方法
- E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
- NYOJ131 小数相加 【字符串】
- 从一个应用程序跳转到另一个应用程序
- 完美3分球埃弗里-布拉德利9投6中
- linux下释放cache内存
- android基础笔记——自定义控件和视图:下拉菜单
- UVA - 993 Product of digits