1#include <iostream>2 3 using namespacestd;4 5 intdp[1000001];6 7 intMain () {8 intN;9 while(Cin >>N) {Tendp[1] =1; Onedp[2] =2; A for(inti =3; I <= N; ++i) { - ifI2==1) -Dp[i] = dp[i-1]; the Else -Dp[i] = dp[i-1] + dp[i/2]; -Dp[i]%=1000000000; - } +cout << Dp[n] <<Endl; - } +
Excerpt: I is odd, split with the previous i-1 is the same, write a few groups on their own to know, do not say more. The key is that I is even when: when the split is not included in the 1 o'clock, the split is the smallest to 2, then the split with I/2 is one by one corresponding, when the split contains 1 o'clock, the first to take this 1 out, the remaining i-1 to split, the situation with the i-1 of the split to one of the corresponding , and the two split cases are disjoint (because one does not have 1, one has 1), then the addition of I is even when the split case.
Good way, I can't think of whining
Nine degrees [1084] integer split