当前位置:网站首页>H - Sumsets POJ 2229
H - Sumsets POJ 2229
2022-06-26 13:09:00 【YJEthan】
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
When i When it's odd a[i]=a[i-1]
When i When it's even a[i]=a[i-1]+a[i/2]
#include<stdio.h>
int a[1000100];
int main()
{
int i,n;
a[1]=1;a[2]=2;
for(i=3;i<1000100;i++)
{
if(i&1)
{
a[i]=a[i-1]%1000000000;
}
else a[i]=(a[i/2]+a[i-2])%1000000000;
}
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",a[n]);
}
}边栏推荐
- H - Sumsets POJ 2229
- IDC报告:百度智能云AI Cloud市场份额连续六次第一
- Do you know the limitations of automated testing?
- 利用scrapy爬取句子迷网站优美句子存储到本地(喜欢摘抄的人有福了!)
- Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
- 中国剩余定理模板题 互质与非互质
- Electron official docs series: Processes in Electron
- I - Dollar Dayz
- 软件测试报告应该包含的内容?面试必问
- sql 将数据表b字段值赋值到数据表a中某一列
猜你喜欢
随机推荐
黑马笔记---常用API
Common creation and usage of singletons
Use the script to crawl the beautiful sentences of the sentence fan website and store them locally (blessed are those who like to excerpt!)
倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用
体现技术深度(无法速成)
System tasks (display / print class) in Verilog - $display, $write, $strobe, $monitor
Is it safe for the head teacher to open a stock account and open an account for financial management?
【网络是怎么连接的】第一章:浏览器生成消息
Sinotech software outsourcing
倍福TwinCAT3 NCI在NC轴界面中的基本配置和测试
Adobe Acrobat prevents 30 security software from viewing PDF files or there are security risks
Angle de calcul POSTGIS
Explain C language 11 in detail (C language series)
Processsing 鼠标交互 学习
享元模式(Flyweight)
自动化测试的局限性你知道吗?
P2393 yyy loves Maths II
UVA10341 solve it 二分
D - 滑雪
POJ 3070 Fibonacci









