当前位置:网站首页>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 元边栏推荐
- 图像识别与检测--笔记
- The concept of C language pointer
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
- Responsive MySQL of vertx
- 【LeetCode】2. Valid Parentheses·有效的括号
- 【MySQL 13】安装MySQL后第一次修改密码,可以可跳过MySQL密码验证进行登录
- Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)
- Web router of vertx
- 技术干货|AI框架动静态图统一的思考
- Common operations of JSP
猜你喜欢

图像识别与检测--笔记
![[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)](/img/d8/b4f39d9637c9886a8c81ca125d6944.jpg)
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)

Lucene hnsw merge optimization

Why is data service the direction of the next generation data center?

Collector in ES (percentile / base)

技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer

Go language foundation ------ 12 ------ JSON

PAT甲级 1031 Hello World for U

Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing

昇思MindSpore再升级,深度科学计算的极致创新
随机推荐
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估
Epoll related references
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Leetcode 213: looting II
Structure of golang
項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
密西根大学张阳教授受聘中国上海交通大学客座教授(图)
技术干货|AI框架动静态图统一的思考
Lucene introduces NFA
圖像識別與檢測--筆記
Iterm2设置
PAT甲级 1032 Sharing
[mindspire paper presentation] summary of training skills in AAAI long tail problem
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
Web router of vertx
IO stream system and FileReader, filewriter
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Go language foundation ----- 16 ----- goroutine, GPM model
输入三次猜一个数字