Story of HDU 2018 cows, story of hdu2018 cows

Source: Internet
Author: User

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]);}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.