Farmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power of 2. Here are the possible sets of numbers that sum to 7:

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

A single line with a single integer, N.

Output

The number of ways to represent N as the indicated sum. Due to the potential huge size of this number, print only last 9 digits (in base 10 representation).

Sample Input

7

Sample Output

6
#include<iostream>
#include<algorithm>
using namespace std;
int dp[];
int mod=1e9;
int main(){
int n;
cin>>n;
dp[]=;
for(int i=;i<=n;i++){
if(i%==){
dp[i]=dp[i-];
}
else{
dp[i]=(dp[i-]+dp[i>>])%mod;
}
}
cout<<dp[n]<<endl;
return ;
}

最新文章

  1. [LeetCode] Alien Dictionary 另类字典
  2. 第四章 电商云化,4.2 集团AliDocker化双11总结(作者: 林轩、白慕、潇谦)
  3. 【jQuery】百分比自适应屏幕轮播图特效
  4. Hibernate注解映射联合主键的三种主要方式
  5. MySQL的InnoDB索引原理详解 (转)
  6. spring 小结
  7. List&lt;T&gt;
  8. HDU 1053 &amp; HDU 2527 哈夫曼编码
  9. Mysql支持中文全文检索的插件mysqlcft-应用中的问题
  10. Firefly安装说明 与 常见问题
  11. HW6.17
  12. underscorejs-groupBy学习
  13. AtCoder Beginner Contest 068
  14. 基于Swt、ffmpeg、jacob、vlc、SApi、h2技术编写简单的旁白生成器
  15. mongo中命令工作原理
  16. Embedded training,嵌入式训练
  17. 第一篇:服务的注册与发现Eureka(Finchley版本)
  18. bzoj 2120 数颜色 (带修莫队)
  19. kafka 的 docker 镜像使用
  20. rtmp和http方式在播放flv方面的各自优势和劣势

热门文章

  1. JAVA课堂动手动脑实验--方法的重载定义,组合数的递归算法
  2. 富文本编辑器--FCKEditor 上传图片
  3. Kali Linux 网络扫描秘籍
  4. XiaoKL学Python(C)__future__
  5. usr/include/c++/6.4.1/bits/stl_relops.:67: Parse error at &quot;std&quot;
  6. Codeforces559C Gerald and Giant Chess
  7. BZOJ 1969 航线规划 - LCT 维护边双联通分量
  8. lazarus,synedit输入小键盘特殊符号的补丁
  9. 企业官网Web原型制作分享-Tesla
  10. Subarray Product Less Than K LT713