HDOJ_2709_Sumsets

AC代码:

#include <iostream>
#include <cstdio>
#define Max 1000005
using namespace std;

long long int a[Max];

void hanshu()
{
    a[1]=1;a[2]=2;
    for(long long int j=3;j<=1000001;j++)
    {
        if(j%2==1)
            a[j]=a[j-1];
        else
            a[j]=(a[j/2] + a[j-2])%1000000000;
    }
        
}


int main(void)
{
    freopen("in.txt","r",stdin);
    hanshu();
    long long int N;
    while(scanf("%lld",&N)!=EOF)
    {
        printf("%lld\n",a[N]);
    }
    
    fclose(stdin);
    return 0;
}

 

posted @ 2018-11-11 10:17  pha创噬  阅读(109)  评论(0编辑  收藏  举报