How to solve the problem of hdu1205 eating candy

Source: Internet
Author: User

It's not that difficult to think about it.

Put the most M (max in total) into a column, generating an interval of max-1, for M, other sweets are heterogeneous (total sum-max ), can be used to fill the interval, but if sum-max <max-1, the interval cannot be filled, so there will be adjacent M, not meeting the requirements printf ("NO \ n ");

When sum-max> = max-1, the m interval must be filled with printf ("Yes \ n ");

Note that the sum value is large.

 

Choose one of the different types of candy n (n <= sum-max) to fill in the interval, and then merge M and N to replace the previous m.

Loop back to end

Mmmmm nnnn bbbb vvv CC x

 

 

Insert from the arrow

Bytes

M m

Bytes

Mn m

Bytes

MNB Mn MB

Bytes

Mnbv MNB mnv mbv

Bytes

Mnbv mnbc mnv mbv

Mnbv mnbc mnvx mbv

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.