标签:
Time Limit: 2000MS | Memory Limit: 200000K | |
Total Submissions: 15052 | Accepted: 6001 |
Description
Input
Output
Sample Input
7
Sample Output
6
Source
#include <cmath> #include <cstdio> const int MOD = 1e9; const int N = 1000001; int num[N]; void Sieve(){ num[1] = 1; num[2] = 2; num[3] = 2; for(int i = 4; i <= N; i++){ if(i & 1) num[i] = num[i-1]; else num[i] = (num[i-2]%MOD + num[i/2]%MOD)%MOD; } } int main(){ Sieve(); int n; while(scanf("%d", &n) != EOF) printf("%d\n", num[n]); return 0; }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/5064645.html