Story of HDU 2018 cows, story of hdu2018 cows
In recursive mode, the ox is divided into two types to find the corresponding relationship.
Today, I suddenly found that such a question is also DP. I used to think that it is a regular expression or something.
To sum up the two DP questions we have encountered, the recurrence of DP is based on the timeline and path line, and the results are classified. These are important.
# Include <stdio. h> int dp [60] [2]; // dp [I] [0]: DDP on the I day [I] [1]: day I, mavericks int main () {int n; # ifndef ONLINE_JUDGEfreopen ("in.txt", "r", stdin); # endifdp [1] [0] = 1; dp [2] [0] = 1; dp [3] [0] = 1; dp [4] [0] = 1; dp [1] [1] = 0; dp [2] [1] = 1; dp [3] [1] = 2; dp [4] [1] = 3; for (int I = 5; I <= 55; I ++) {dp [I] [0] = dp [I-1] [0] + dp [I-3] [0]; // when a calf grows into a big cow, it will be born immediately, that is, three years later, 4th-Year-Old dp [I] [1] = dp [I-1] [1] + dp [I-1] [0];} while (scanf ("% d ", & n), n) {printf ("% d \ n", dp [n] [0] + dp [n] [1]);}