当前位置:网站首页>权重等比分配
权重等比分配
2022-08-01 05:21:00 【時間不夠以後】
function getA(total, len){
// 正常情况下,返回有len个元素的数组,每个元素是对应任务数
if(total<0 || len<=0) return []; // 返回为空数组表示输入数据有错
var avgNum = Math.floor(total / len / total * 10000) / 100 // 平均数
var avgAll = Math.floor(avgNum * len * 100) / 100 // 平均数总和
var rest = Math.floor((total - avgAll) * 100) / 100
var res=[]
let i=-1
while(++i<len){
let tem=avgNum;
if(i < rest * 100) {
tem = Math.round((tem + 0.01) * 100) / 100.00
}
res.push(tem)
}
return res;
}
console.log(getA(100, 15))
function average(t, c) {
var l = [], a = t / c | 0, b = t % c, i = -1;
while (++i < c) l[i] = +(i < b) + a;
return l;
}
console.log(average(100, 15))
边栏推荐
猜你喜欢
可持久化线段树
字符中的第一个唯一字符
备战金九银十,如何顺利通过互联网大厂Android的笔面试?
混合型界面:对话式UI的未来
万字逐行解析与实现Transformer,并进行德译英实战(一)
Power button (LeetCode) 212. The word search II (2022.07.31)
使用string 容器翻转 字母
Induction jian hai JustFE 2022/07/29 team, I learned the efficient development summary (years)
MySQL-Data Definition Language-DDLdatebase define language
Robot_Framework:断言
随机推荐
说说js中使用for in遍历数组存在的bug
七、MFC序列化机制和序列化类对象
pytroch、tensorflow对比学习—搭建模型范式(构建模型方法、训练模型范式)
Robot_Framework: keyword
4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
小心你的字典和样板代码
Selenium:元素判断
Selenium: Manipulating Cookies
MySQL-数据定义语言-DDLdatebase define language
MySQL-数据操作-分组查询-连接查询-子查询-分页查询-联合查询
(2022牛客多校四)N-Particle Arts(思维)
WPF项目-初步了解数据绑定 binding
对话MySQL之父:一个优秀程序员可抵5个普通程序员
I met a shell script
What should I do if the neural network cannot be trained?
(2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
LeetCode 27. 移除元素
2022.7.26 Mock Competition
状态压缩dp
After the image is updated, Glide loading is still the original image problem