当前位置:网站首页>权重等比分配
权重等比分配
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))
边栏推荐
- Robot_Framework: Assertion
- 2022.7.26 Mock Competition
- NDK does not contain any platforms问题解决
- (2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
- 【翻译】确保云原生通信的安全:从入口到服务网及更远的地方
- 程序员代码面试指南 CD15 生成窗口最大值数组
- NUMPY
- Selenium: mouse, keyboard events
- Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
- MySQL-数据定义语言-DDLdatebase define language
猜你喜欢
NDK does not contain any platforms problem solving
AspNet.WebApi.Owin custom Token request parameters
leetcode125 验证回文串
SL-12/2过流继电器
WPF项目-初步了解数据绑定 binding
对话MySQL之父:一个优秀程序员可抵5个普通程序员
[target detection] YOLOv7 theoretical introduction + practical test
pytorch、tensorflow对比学习—功能组件(激活函数、模型层、损失函数)
Selenium:弹窗处理
Qt Widget 项目对qml的加载实例
随机推荐
可视化全链路日志追踪
vim配置+ctag像source insight一样方便阅读代码
leetcode43 字符串相乘
Selenium: upload and download files
【MySQL必知必会】 表的优化 | 充分利用系统资源
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (2)
vsce package 后出现 Command failed: npm list --production --parseable --depth=99999 --loglevel=error异常
Selenium: Popup Handling
Hunan institute of technology in 2022 ACM training sixth week antithesis
Selenium: browser operation
微信小程序获取手机号phonenumber.getPhoneNumber接口开发
LeetCode 9. 回文数
Seleniu:元素常用操作
ApiFile
WPF入门项目必知必会-初步了解数据绑定 binding
2022.7.26 Mock Competition
Selenium:元素等待
冲刺金九银十,Android开发面试(内含面试资料|面试题|源码)
WPF项目-初步了解数据绑定 binding
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (a)