当前位置:网站首页>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 边栏推荐
- Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition
- Segment read
- Pat class a 1028 list sorting
- 技术干货|关于AI Architecture未来的一些思考
- 技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估
- Implementation of breadth first in aggregation in ES
- Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
- Structure of golang
- 技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务
- 技术干货|百行代码写BERT,昇思MindSpore能力大赏
猜你喜欢

Pat class a 1032 sharing

【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
![[mindspire paper presentation] summary of training skills in AAAI long tail problem](/img/34/9c9ec1b94edeecd4a3e7f20fdd8356.png)
[mindspire paper presentation] summary of training skills in AAAI long tail problem

HCIA notes

Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition

EtherCAT state machine transition (ESM)

项目经验分享:基于昇思MindSpore实现手写汉字识别

Technical dry goods Shengsi mindspire dynamic transformer with variable sequence length has been released!

Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task

Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
技术干货|AI框架动静态图统一的思考
C2-关于VCF文件合并的几种方法
Go language - loop statement
【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表
[MySQL 12] MySQL 8.0.18 reinitialization
Usage of requests module
go语言-循环语句
GoLang之结构体
华为交换机配置ssh登录远程管理交换机
static关键字
昇思MindSpore再升级,深度科学计算的极致创新
【LeetCode】2. Valid parentheses · valid parentheses
【LeetCode】4. Best time to buy and sell stock
Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
Go language foundation ----- 06 ----- anonymous fields, fields with the same name
Pat class a 1032 sharing
Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing
Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!
Introduction of novel RNA based cancer therapies
Responsive MySQL of vertx