当前位置:网站首页>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]);
}
}边栏推荐
- Research and development practice of Kwai real-time data warehouse support system
- opencv高速下载
- 机组实践实验8——使用CMStudio设计基于基本模型机微程序指令(1)
- postgis计算角度
- P5733 【深基6.例1】自动修正
- [esp32-C3][RT-THREAD] 基于ESP32C3运行RT-THREAD bsp最小系统
- ES6:迭代器
- Less than 40 lines of code to create a blocprovider
- find及du -sh显示权限不够的解决方法
- 自动化测试的局限性你知道吗?
猜你喜欢

倍福Ethercat模块网络诊断和硬件排查的基本方法

Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control

别乱用 FULL_CASE 和 PARALLEL_CASE

openlayers 绘制动态迁徙线、曲线
![[BSidesCF 2019]Kookie 1](/img/22/585d081668e67b8389a1b90aaebe9d.png)
[BSidesCF 2019]Kookie 1

倍福NC轴状态转移图解析

倍福PLC基于CX5130实现数据的断电保持

Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
solo 博客系统的 rss 渲染失败

Processing 多面体变化
随机推荐
Word文档导出(使用固定模板)
How does easygbs solve the abnormal use of intercom function?
power designer - 自定义注释按钮
Angle de calcul POSTGIS
A must for programmers, an artifact utools that can improve your work efficiency n times
Processing 多面体变化
Redis learning - 03 transaction
[极客大挑战 2019]RCE ME 1
QT .pri 的建立与使用
详细讲解C语言11(C语言系列)
深度解析当贝盒子B3、腾讯极光5S、小米盒子4S之间的区别
Adobe Acrobat阻止30款安全软件查看PDF文件 或存在安全风险
软件测试报告应该包含的内容?面试必问
倍福EtherCAT Xml描述文件更新和下载
[BSidesCF 2019]Kookie 1
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
初识-软件测试
KVM 显卡透传 —— 筑梦之路
Group counting practice experiment 9 -- using cmstudio to design microprogram instructions based on segment model machine (2)
Electron official docs series: References