这篇文章主要介绍了JAVA实现红包分发的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。如果发总金额为 m的 n 个红包,先用一个长度为 n的临时数组 a 存放 n个随机双精度小数 ,然后用 sum表示数组 a 的和,每个红包的金额
Java高性能高并发实战-秒杀系统优化方案 https://www.ffu9.com/2021/02/16/227.html
import java.util.Arrays;
import java.util.Random;
import java.math.*;
import java.util.Scanner;
public class Main {
public static long now_time;
public static long seed;
public static int[] get_red_packets(int money, int num) {
Random random = new Random(seed);
seed = random.nextLong();
int[] res = new int[num];
double[] temp