Man and Monkey assign coconut problem

Source: Internet
Author: User

Five men and a monkey are on an island. They spent the first night harvesting coconuts. At night, a man wakes up and decides to take his share of the coconut. He is divided into five parts. The coconut left one, he gave it to the monkey, then hid his share and went back to sleep.
Soon another man woke up and did the same thing. Divided into 5 parts of the coconut, the remaining one to the monkeys, take their own, and back to bed. Third, the fourth and fifth men are the same. The next morning they were all awake, and their remaining coconut was divided into five halves. This time no coconut was left behind.
Question to enter an n, the number of coconut, let p, the largest number of people can meet this condition, divided p times, each time just left a monkey, the last province of the number is exactly the number of multiples

F (n <0>) = n;
F (n <i+1>,p) = (f (n <i>)-1) * (p-1)/p; 0 <= i < p;
F (n <p>,p) = Pm,m is an integer.

Elimination f (n <p>,p) has
PM = n * ((p-1)/P) ^p-sum (((p-1)/p) ^i, i=1:p)
PM = n * ((p-1)/p) ^p + (P-1) (((p-1)/p) ^p-1)

The function images of ((p-1)/p) ^p are as follows: 1, p < 5 o'clock guide values are very large, the fastest growth.
2, P >= 4 o'clock, value over 0.3
3, p = 24 o'clock, value over 0.36
4, p until million, the value is still 0.3679

It is therefore considered that ((p-1)/p) ^p < 0.37, the
PM < 0.37n-0.63 (p-1)

When m = 1 o'clock, p max, there
1.63p < 0.37n + 0.63, ignoring constant entries
Can get P < 0.227n
So the value range of P is very small. In fact, M could be much bigger than 1.

So let's see, when m = 1, the relationship between P and N, where p and n should be integers
p = 1:1: 3*1e7
When p = 2, n = 11 is an integer. That is, test 30 million p, when m = 1 o'clock, only p = 2 N = 11 satisfies the condition
That is, M = 1 Only one exception is established.

More generally the case M > 1, for example m = 2 o'clock.
Can get p < 0.14n, smaller.
When m = 2 o'clock, the relationship between P and N:
p = 1:1: 3*1e7
When P = 2, 3, 24283182, n = 19, 25, and 173742417 are integers.
m = 3.
Can get p < 0.102n, smaller.
When P = 2, 18138042, n = 27, 179079202 is an integer.
m = 4.
Can get p < 0.0799n, small bar.
When P = 2, 14384493, 17952777, n = 35, 181121042, 226050766 is an integer
m = 5.
Can get P < 0.066n
When p = 2 o'clock, n = 43 is an integer
m = 6.
Can get P < 0.056n
When P = 2, 17275954, 29680590, n = 51, 311450436, 535080878
m = 7
P < 0.0485n
p = 2, 14333173, 17300311, 26742099, n = 59, 297359666, 358916666, 554798405

Contingency, the test of large number of cases P is 2 of the majority, or, the island has tens of millions of people divided into tens of billions of coconut ... It's a problem where those coconuts are put.

Last measurement of a M = 100

P < 0.0037n, this is too small, 3 per thousand.

p = 2 4588077 5872121 7366469 9074646 11807665 15939607 18255034 20749254 22115823 22955497 23585595 26559095 27414265 276 42455 27929303 29690190

n = 803 1255052379 1606298075 2015071687 2482337469 3229945155 4360223282 4993600150 5675885221 6049705324 6279395176

There are still 2 of people in the situation.

Conclusion: P is taken to 30 million people to measure the condition that P and n are equal integers. M is the number of coconuts to be divided for the last time and must be an integer value. P is more than 2 o'clock. The test gives several possibilities. By the formula, the Traverse range of P can be very small compared to n. Some people from the n-2 began to traverse, in fact, from the results can be seen, almost 99% of the situation is not working hard.

This is an ACM problem, the original paste see

Http://topic.csdn.net/u/20090530/10/dc60c446-c153-42e7-a39d-597d1f307773.html

I made a mistake in the original Post's reply and corrected it in this article.

Test code:

>> p = 1:1: 3 * 1E7; >> n = NP (p), >> r = Find (n = = Round (n)); >> r >> N (r )//np.m function y = NP (x, m) n = length (x); MM = m + 1; y = zeros (1, n); For i = 1:1: N xx = x (i); Y (i) = (MM * xx-1) * ((XX/(xx-1)) ^xx) + 1-xx; End End

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.