How to deal with the principle of stealing red envelopes

Source: Internet
Author: User
The principle of stealing red envelopes
Want to use PHP to achieve the function of red envelopes, who send the more red envelopes, Rob more, do not know if what algorithm appropriate
------to solve the idea----------------------
I think of a way of thinking I do not know the appropriate (Novice mo spray)
Set up two random numbers, say one is 0-100 random to how much to give red envelopes such as this number is 1-10 corresponding to get red envelopes, your probability is 10%
Another random number range 0-50 randomly get a number such as also 1-10 corresponds to get red envelopes so the probability is 20% opposite;
Whether it's the first or the second, according to the TOP10 in the database.
That's just my idea.
------to solve the idea----------------------
You'll record the number of red envelopes each person sends (amount)
So you will know the number of red envelopes (amount) of a person, the proportion of the total number of red envelopes (amount)
According to this proportion can meet who sent the more red envelopes, Rob also more requirements
  • 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.