. Zhejiang PAT 2-10 pirate spoils - Classic Game

The meaning of problems

After P pirates stole diamonds D spoils ($ 3 \ leq P, D \ leq 100 $), using the spoils strategy:

From No. 1, proposed an allocation scheme of gold, if we can get an absolute majority, including No. 1, including (ie, greater than half) agreed that the implementation of the program, otherwise it will be No. 1 into the sea to feed sharks; then followed by a similarly No. 2, No. 3 and so on pirates mentioned embodiment.

And there assumptions: 1 very smart, always maximize the benefits to the individual as a code of conduct; 2 in the case can get as many diamonds, the pirates do not intentionally cause accomplices to death;..

analysis

Backwards analysis,

Suppose a common case, individual points 7 10 diamonds.

If only two people, then no matter what 2 say 1 would be opposed, unless he put diamonds all to him. That is the following situation.  

    (0,10)   

If only 3 people, 3 know if he was dead situation 2, if you want to achieve as long as their proposal for an individual's consent enough. So give No. 3 2 2 diamond will agree to the proposal 3, otherwise they can not get the one. This becomes:

    (9,1,0)

If only four people, four know if he was dead Scheme 3, if you want your proposal to achieve as long as two individuals agreed to fight just fine. No. 4 would give it more than 2 diamond, a diamond to No. 1, 1 and 2 will be agreed with the proposal 4. This becomes:

    (7,0,2,1)

If only 5 people, 5 know if he was dead of Scheme 4, if you want your proposal to achieve as long as two individuals agreed to fight just fine. So give 5 No. 3 a diamond, to No. 12 diamonds. This becomes:                                                      

    (7,0,1,0,2)

If only 6 people, 6 know if he was dead program 5, if you want to achieve as long as their proposals for three people agree enough. So give No. 6 4,2 diamond, to No. 32 diamonds. This becomes:                                                      

    (6,0,1,2,1,0)

Now we can launch 7 individual cases, and 7 know if he was dead program 6, if you want your proposal to achieve as long as three individuals agreed to fight just fine. So give No. 7 4,2 diamond, to No. 32 diamonds. This becomes:

    (6,0,1,2,0,0,1)

When boils down to this, there is $ i $ personal, knowing the case when $ i-1 $ personal, so choose a minimum of $ i / 2 $ each on front and give a round.

Specific rule is $ P> $ 3, total $ i / 2-1 $ 1-a and 2; when $ p = 3 $ is $ (D-1 \ \ 1 \ 0) $.

Code implementation should be very simple. Slightly

 

 

Reference Links: http://www.voidcn.com/article/p-cxovyfju-qm.html

 

Guess you like

Origin www.cnblogs.com/lfri/p/11610543.html