Javascript-ask a question about the lottery Algorithm

Source: Internet
Author: User
For a total of 5000 yuan, I want to issue 4888 yuan prize each prize (1 yuan-1.5 yuan). How can I ensure that I have just paid 4888 yuan for the first prize? Total 5000 yuan
4888 prizes to be issued
Each Prize (1 RMB-1.5 RMB)

How can we ensure that we have just paid 4888 yuan for the first prize?

Reply content:

Total 5000 yuan
4888 prizes to be issued
Each Prize (1 RMB-1.5 RMB)

How can we ensure that we have just paid 4888 yuan for the first prize?

5000 divided by 4888, and each prize is about 1.02 on average. The range of the prize given in the question is 1 to 1.5. We can see that the average value is much closer to the lower limit than the upper limit. Therefore, the bonus amount between 1 and 1.5 cannot be completely randomly distributed.

If you only make sure that you have successfully received 4888 yuan, you can use many solutions, suchFoolyouAccording to the rules, the number of different bonus amounts should be guaranteed to be 5000 of the total amount, or the linear planning method should be adopted. However, there will be a lot of solutions without too many restrictions in the conditions of the questions.

4408 pieces of 1, 200 1.1, 100 1.2, 50 1.3, 80 1.4, 50 1.5.

There are a lot of answers, and the one that gets together upstairs can be used.

The prize is 1.0 ~ 1.5. In theory, there are several possible bonuses, for example, 1.01234567 yuan. However, this is too complicated and not necessary. There are six possible possibilities: 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 yuan, respectively ~ X6.

It is better to solve the multiple linear equations:

(1) 5000 = 1.0x1 + 1.1x2 + 1.2x3 + 1.3x4 + 1.4x5 + 1.5x6
2) 4888 = x1 + x2 + x3 + x4 + x5 + x6
(3) x1, x2. .., x6 are non-negative integers.

You can find a group of solutions.

Related Article

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.