标签:
Time Limit: 2000MS | Memory Limit: 200000K | |
Total Submissions: 14344 | Accepted: 5709 |
Description
Input
Output
Sample Input
7
Sample Output
6
Source
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 5 using namespace std; 6 7 const int maxn=1000000+3; 8 9 #define LL long long 10 11 LL dp[maxn]; 12 const LL mod=1000000000; 13 14 int main() 15 { 16 dp[0]=dp[1]=1; 17 for(int i=2;i<maxn;i++) 18 { 19 if(i%2) 20 dp[i]=dp[i-1]; 21 else 22 dp[i]=dp[i-2]+dp[i/2]; 23 while(dp[i]>=mod) 24 dp[i]-=mod; 25 } 26 27 int N; 28 while(~scanf("%d",&N)) 29 { 30 printf("%d\n",dp[N]); 31 } 32 33 return 0; 34 }
标签:
原文地址:http://www.cnblogs.com/-maybe/p/4603425.html