当前位置:网站首页>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]);
}
}边栏推荐
- 倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器
- OPLG: 新一代云原生可观测最佳实践
- Unit practice experiment 8 - using cmstudio to design microprogram instructions based on basic model machine (1)
- 复制多个excel然后命名不同的名字
- H - Sumsets POJ 2229
- How does easygbs solve the abnormal use of intercom function?
- First knowledge - Software Testing
- 倍福PLC通过MC_ReadParameter读取NC轴的配置参数
- 倍福CX5130换卡对已有的授权文件转移操作
- What are the common categories of software testing?
猜你喜欢
随机推荐
Electron official docs series: Processes in Electron
倍福通过CTU和TON实现时间片大小和数量的控制
详细讲解C语言10(C语言系列)
Verilog中的系统任务(显示/打印类)--$display, $write,$strobe,$monitor
享元模式(Flyweight)
Biff TwinCAT can quickly detect the physical connection and EtherCAT network through emergency scan
Common creation and usage of singletons
倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器
Dark horse notes - Common APIs
Summary of wechat applet test points
J - Wooden Sticks poj 1065
Electron official docs series: Distribution
10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
Processing function translate (mousex, mousey) learning
Bridge mode
Angle de calcul POSTGIS
C语言:练习题二
倍福TwinCAT3实现CSV、TXT文件读写操作
详细讲解C语言11(C语言系列)
Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis









