HDU 1538 A puzzle for Pirates: Game & Pirate spoils problem

Source: Internet
Author: User
Tags time limit

Time limit:2000/1000 MS (java/others)

Memory limit:65536/32768 K (java/others)

Problem Description

A bunch of pirates have gotten their hands on a hoard of gold pieces and wish to divide the loot. They are Democratic pirates in their own way, and it are their custom to make such divisions in the following manner:the F Iercest Pirate makes a proposal about the division, and everybody on it, votes the including. If percent or more are in favor, the proposal passes and is implemented forthwith. Otherwise the proposer is thrown overboard, and the procedure are repeated with the next fiercest pirate. The Pirates enjoy throwing one of their fellows overboard, but if given a choice they prefer cold, hard cash, the more The better. They dislike being thrown overboard themselves. All pirates are rational and know this other pirates are rational. Moreover, no two pirates are equally fierce, so there is a precise pecking order-and it are known to them all. The gold pieces are indivisible, and arrangements to share pieces-are not permitted, because no pirate trusts his FEllows to stick to such a arrangement. It ' s every man for himself. Another thing about pirates is that they are realistic. They believe ' a bird in the hand are worth two in the bush ' which means the They prefer something this is certain than a r ISK to get more, where they might lose everything. For convenience, number the Pirates in order of meekness, so this least fierce is number 1, the next least fierce Er 2 and so on. The fiercest pirate thus gets the biggest number, and proposals proceed in the order from the biggest to the least. The secret to analyzing all such games of strategy are to work backward from the end. The "place" to "start" is the "point" at which the game gets down to just two pirates, P1 and P2. Then Add in Pirate P3, P4, ..., one by one. The illustration shows the results when 3, 4, and 5 pirates try to divide of gold. Your task is to predict how many gold pieces a given pirate'll get.

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.