当前位置:网站首页>PHP微信抢红包的算法
PHP微信抢红包的算法
2022-07-03 07:41:00 【.周周】
php微信红包算法
function qiangHongbao() {
$total=10;//总额
$num=8;// 分成8个红包,支持8人随机领取
$min=0.01;//每个人最少能收到0.01元
for ($i=1;$i<$num;$i++) {
$safe_total=($total-($num-$i)*$min)/($num-$i);//随机安全上限
$money=mt_rand($min*100,$safe_total*100)/100;
$total=$total-$money;
echo '第'.$i.'个红包:'.$money.' 元,余额:'.$total.' 元 <br/>';
}
echo '第'.$num.'个红包:'.$total.' 元,余额:0 元';
}
// 输出结果
// 第1个红包:0.08 元,余额:9.92 元
// 第2个红包:0.82 元,余额:9.1 元
// 第3个红包:1.4 元,余额:7.7 元
// 第4个红包:0.87 元,余额:6.83 元
// 第5个红包:1.07 元,余额:5.76 元
// 第6个红包:2.47 元,余额:3.29 元
// 第7个红包:1.01 元,余额:2.28 元
// 第8个红包:2.28 元,余额:0 元边栏推荐
- PAT甲级 1031 Hello World for U
- Introduction of transformation flow
- Use of other streams
- Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
- 华为交换机:配置telnet和ssh、web访问
- 技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
- 技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
- Logging log configuration of vertx
- Pgadmin 4 v6.11 release, PostgreSQL open source graphical management tool
- Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
猜你喜欢

Qtip2 solves the problem of too many texts

Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake

Usage of requests module

技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!

Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once

Application of pigeon nest principle in Lucene minshouldmatchsumscorer

项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现

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

Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction

Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
opensips与对方tls sip trunk对接注意事项
Unified handling and interception of exception exceptions of vertx
Reconnaissance et détection d'images - Notes
Some basic operations of reflection
Lucene merge document order
Lucene introduces NFA
Common architectures of IO streams
技术干货|关于AI Architecture未来的一些思考
An overview of IfM Engage
Usage of requests module
Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
Use of other streams
Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
IO stream system and FileReader, filewriter
Read config configuration file of vertx
PAT甲级 1029 Median
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Epoll related references
Logging log configuration of vertx
The babbage industrial policy forum