当前位置:网站首页>H - Sumsets POJ 2229
H - Sumsets POJ 2229
2022-06-26 12:40: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
当i为奇数的时候a[i]=a[i-1]
当i为偶数的时候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]);
}
}边栏推荐
猜你喜欢

倍福将EtherCAT模块分到多个同步单元运行--Sync Units的使用

倍福CX5130换卡对已有的授权文件转移操作

第十章 设置结构化日志记录(二)

processing 函数translate(mouseX, mouseY)学习

【网络是怎么连接的】第二章(下):一个网络包的接收
Adobe Acrobat prevents 30 security software from viewing PDF files or there are security risks

第01章_Linux下MySQL的安装与使用

Splunk iowait 报警的解决

倍福PLC基于NT_Shutdown实现控制器自动关机重启

Tiger DAO VC产品正式上线,Seektiger生态的有力补充
随机推荐
机器学习笔记 - 时间序列的季节性
Software testing - concept
Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control
Don't mess with full_ Case and parallel_ CASE
power designer - 自定义注释按钮
微信小程序测试点总结
Word文档导出(使用固定模板)
【网络是怎么连接的】第二章(上): 建立连接,传输数据,断开连接
openlayers 绘制动态迁徙线、曲线
Go 结构体方法
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
Tiger DAO VC产品正式上线,Seektiger生态的有力补充
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
国标GB28181协议EasyGBS级联宇视平台,保活消息出现403该如何处理?
map 取值
MySQL 自定义函数时:This function has none of DETERMINISTIC, NO SQL 解决方案
Electron official docs series: Contributing
倍福CX5130换卡对已有的授权文件转移操作
软件测试测试常见分类有哪些?
postgis计算角度