当前位置:网站首页>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]);
}
}边栏推荐
猜你喜欢

P2393 yyy loves Maths II

Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis

享元模式(Flyweight)

Software testing - concept

Explain C language 10 in detail (C language series)

倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器

Goto statement to realize shutdown applet

Word文档导出(使用固定模板)

IDC报告:百度智能云AI Cloud市场份额连续六次第一

Solution of Splunk iowait alarm
随机推荐
机器学习笔记 - 时间序列的季节性
复制多个excel然后命名不同的名字
KVM video card transparent transmission -- the road of building a dream
倍福EtherCAT Xml描述文件更新和下载
Lightflow completed the compatibility certification with "daocloud Enterprise Cloud native application cloud platform"
B - Bridging signals
tauri vs electron
倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用
D - skiing
Echart堆叠柱状图:色块之间添加白色间距效果设置
Go structure method
Typescript
倍福TwinCAT3实现CSV、TXT文件读写操作
Electron official docs series: Examples
C# const详解:C#常量的定义和使用
Dark horse notes - Common APIs
Openlayers drawing dynamic migration lines and curves
黑马笔记---常用API
Chapter 01_ Installation and use of MySQL under Linux
Electron official docs series: Distribution