POJ 2229 Sumsets
| Time Limit: 2000MS | Memory Limit: 200000K | |
| Total Submissions: 11892 | Accepted: 4782 |
Description
1) 1+1+1+1+1+1+1
2) 1+1+1+1+1+2
3) 1+1+1+2+2
4) 1+1+1+4
5) 1+2+2+2
6) 1+2+4
Help FJ count all possible representations for a given integer N (1 <= N <= 1,000,000).
Input
Output
Sample Input
7
Sample Output
6
Source
#include <cstdio>
int a[1000005];
int mod=1e9;
int dp[355][355];
int main ()
{int i,n;
a[1]=1;
a[2]=2;
for(i=3;i<=1000000;i++)
if(i&1) a[i]=a[i-1];
else a[i]=(a[i-2]+a[i>>1])%mod;
while(~scanf("%d",&i))
{
printf("%d\n",a[i]);
}
return 0;
}
好经典的题目。居然a[2]忘记给值了~
POJ 2229 Sumsets的更多相关文章
- poj -2229 Sumsets (dp)
http://poj.org/problem?id=2229 题意很简单就是给你一个数n,然后选2的整数幂之和去组成这个数.问你不同方案数之和是多少? n很大,所以输出后9位即可. dp[i] 表示组 ...
- poj 2229 Sumsets(dp)
Sumsets Time Limit : 4000/2000ms (Java/Other) Memory Limit : 400000/200000K (Java/Other) Total Sub ...
- poj 2229 Sumsets 完全背包求方案总数
Sumsets Description Farmer John commanded his cows to search for different sets of numbers that sum ...
- poj 2229 Sumsets DP
题意:给定一个整数N (1<= N <= 1000000),求出以 N为和 的式子有多少个,式子中的加数只能有2的幂次方组成 如5 : 1+1+1+1+1.1+1+1+2.1+2+2.1+ ...
- poj 2229 Sumsets(dp 或 数学)
Description Farmer John commanded his cows to search . Here are the possible sets of numbers that su ...
- poj 2229 Sumsets(记录结果再利用的DP)
传送门 https://www.cnblogs.com/violet-acmer/p/9852294.html 题意: 将一个数N分解为2的幂之和共有几种分法? 题解: 定义dp[ i ]为数 i 的 ...
- POJ 2229 Sumsets【DP】
题意:把n拆分为2的幂相加的形式,问有多少种拆分方法. 分析:dp,任何dp一定要注意各个状态来源不能有重复情况.根据奇偶分两种情况,如果n是奇数则与n-1的情况相同.如果n是偶数则还可以分为两种情况 ...
- POJ 2229 Sumsets(技巧题, 背包变形)
discuss 看到有人讲完全背包可以过, 假如我自己做的话, 也只能想到完全背包了 思路: 1. 当 n 为奇数时, f[n] = f[n-1], 因为只需在所有的序列前添加一个 1 即可, 所有的 ...
- POJ 2229 Sumsets(规律)
这是一道意想不到的规律题............或许是我比较菜,找不到把. Description Farmer John commanded his cows to search for diffe ...
随机推荐
- c# 根据配置文件路径,设置和获取config文件 appSettings 节点值
/// <summary> /// 获取编译后的主配置文件节点值 /// </summary> /// <param name="key">&l ...
- [OC]宏与const 的使用
Tip: OS日常工作之常用宏定义大全 (摘录文档地址,感觉还不错,例子简单易懂) extern字符串常量,宏定义字符串常量,怎么选? Define与Const专题 extern字符串常量,宏定义字符 ...
- jsp页面输出序号
<c:forEach items="${tests}" var="test" varStatus="s"> <li> ...
- 安装配置dradis
github:https://github.com/dradis/dradis-ce/blob/master/README.md安装出现错误:== Copying sample files == == ...
- Javascript学习笔记:3种递归函数中调用自身的写法
①一般的通过名字调用自身 function sum(num){ if(num<=1){ return 1; }else{ return num+sum(num-1); } } console.l ...
- HDU 5980 Find Small A(寻找小A)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- iOS - AliPay 支付宝支付
1.支付宝支付申请 支付宝支付官方签约集成指引 支付宝APP支付官方集成指引 蚂蚁金服开放平台 1.1 支付宝 APP 支付申请步骤 APP 支付:APP 支付是商户通过在移动端应用 APP 中集成开 ...
- (十一)socket、connect、bind函数详解
一.socket函数 1.头文件: #include <sys/types.h> /* See NOTES */ #include <sys/socket.h> 2.函数原型: ...
- 在Eclipse中,如何把一个java项目变成web项目
经常在eclipse中导入web项目时,出现转不了项目类型的问题,导入后就是一个java项目.解决步骤:1.进入项目目录,可看到.project文件,打开.2.找到<natures>... ...
- windows使用python3.4生成二维码
1.首先下载qrcode库 使用pip命令: pip install qrcode python3.x以上的版本默认是安装好pip的,如果出现无法找到pip指令的信息的话,则需要首先安装pip. 2. ...