当前位置:网站首页>PHP wechat red packet grabbing algorithm
PHP wechat red packet grabbing algorithm
2022-07-03 07:45:00 【. Zhou Zhou】
php Wechat red packet algorithm
function qiangHongbao() {
$total=10;// Total
$num=8;// Divide into 8 Red envelopes , Support 8 People receive at random
$min=0.01;// Everyone can at least receive 0.01 element
for ($i=1;$i<$num;$i++) {
$safe_total=($total-($num-$i)*$min)/($num-$i);// Random safety upper limit
$money=mt_rand($min*100,$safe_total*100)/100;
$total=$total-$money;
echo ' The first '.$i.' Red envelopes :'.$money.' element , balance :'.$total.' element <br/>';
}
echo ' The first '.$num.' Red envelopes :'.$total.' element , balance :0 element ';
}
// Output results
// The first 1 Red envelopes :0.08 element , balance :9.92 element
// The first 2 Red envelopes :0.82 element , balance :9.1 element
// The first 3 Red envelopes :1.4 element , balance :7.7 element
// The first 4 Red envelopes :0.87 element , balance :6.83 element
// The first 5 Red envelopes :1.07 element , balance :5.76 element
// The first 6 Red envelopes :2.47 element , balance :3.29 element
// The first 7 Red envelopes :1.01 element , balance :2.28 element
// The first 8 Red envelopes :2.28 element , balance :0 element 边栏推荐
- Lucene merge document order
- Lucene hnsw merge optimization
- HDMI2.1与HDMI2.0的区别以及转换PD信号。
- When did you find out that youth was over
- The concept of C language pointer
- 基于RNA的新型癌症疗法介绍
- s7700设备如何清除console密码
- Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
- Technical dry goods | some thoughts on the future of AI architecture
- PDO and SDO concepts
猜你喜欢

Pat grade a 1029 median

Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer

Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition

Go language foundation ----- 15 ----- reflection

Leetcode 213: looting II

PAT甲级 1031 Hello World for U

Lucene introduces NFA

Research shows that breast cancer cells are more likely to enter the blood when patients sleep

Technology dry goods | Roberta of the migration of mindspore NLP model - emotion analysis task

Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
随机推荐
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
在浏览器输入url后执行什么
Go language foundation ------ 12 ------ JSON
Precautions for opensips and TLS SIP trunk docking
Leetcode 198: house raiding
Responsive MySQL of vertx
IndexSort
图像识别与检测--笔记
Go language foundation ----- 04 ----- closure, array slice, map, package
The babbage industrial policy forum
Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing
The concept of C language pointer
[MySQL 12] MySQL 8.0.18 reinitialization
Es writing fragment process
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Go language foundation ----- 07 ----- method
技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估
Inverted chain disk storage in Lucene (pfordelta)
static关键字