黑龙江省第七届大学生程序设计竞赛-Heap

描述

A heap is a full binary tree; for each node, its key is greater than its two sub-node’s key. Two heaps are different if there are two nodes which have different keys at the same location. Now we have a problem for you: tell me how many different N-Nodes heaps we can make with N integers?

输入

There are many test cases; for each test case, one line contains only one integer N (1<=N<=1000000) indicating how many nodes the heap has.

输出

For each test case, output one line contains an integer indicating the number of the kinds of the heaps. Because the result might be very large, you can just output the result modular 20000003.

样例输入

1
2
3

样例输出

1
1
2

#include<iostream>
#include<cstdio>
#define MX 1000010
using namespace std;
__int64 a[MX];
int main()
{
     __int64 i;
     __int64 n=5;
     a[1]=1;a[2]=1;
     for(i=3;i<MX-1;i++)
        a[i]=(a[i-1]+a[i-2])%20000003;
     while(~scanf("%lld",&n))
     {
       //  cout<<a[n]<<endl;
         printf("%lld\n",a[n]);
     }
     return 0;
}


评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值