• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
james1207

博客园    首页    新随笔    联系   管理    订阅  订阅

黑龙江省第七届大学生程序设计竞赛-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;
}


 

posted @ 2013-09-02 19:29  Class Xman  阅读(245)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3