当前位置:网站首页>weight distribution
weight distribution
2022-08-01 05:33:00 【not enough time later】
function getA(total, len){
// 正常情况下,返回有len个元素的数组,Each element is the number of corresponding tasks
if(total<0 || len<=0) return []; // Returning an empty array indicates that the input data is incorrect
var avgNum = Math.floor(total / len / total * 10000) / 100 // 平均数
var avgAll = Math.floor(avgNum * len * 100) / 100 // sum of averages
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))
边栏推荐
猜你喜欢
对话MySQL之父:一个优秀程序员可抵5个普通程序员
The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
leetcode125 验证回文串
MySQL-DML language-database operation language-insert-update-delete-truncate
leetcode125 Verify palindrome string
(Codeforce 757) E. Bash Plays with Functions
零序电流继电器器JL-8C-12-2-2
中国的机器人增长
混合型界面:对话式UI的未来
备战金九银十,如何顺利通过互联网大厂Android的笔面试?
随机推荐
(Codeforce 757) E. Bash Plays with Functions
用控件当画笔获得bitmap代码记录
小白的0基础教程SQL: 关系数据库概述 02
Selenium: element judgment
pytroch、tensorflow对比学习—搭建模型范式(构建模型方法、训练模型范式)
2022.7.27好题选讲
matlab simulink 粒子群优化模糊pid控制的电机泵
对话MySQL之父:一个优秀程序员可抵5个普通程序员
leetcode43 string multiplication
第5章——以程序方式处理MySQL数据表的数据
What should I do if the neural network cannot be trained?
Code Interview Guide for Programmers CD15 Generating an Array of Windowed Maximums
Seleniu:元素常用操作
轻量级的VsCode为何越用越大?为什么吃了我C盘10G?如何无痛清理VsCode缓存?手把手教你为C盘瘦身
Jupyter shortcuts
Speed up your programs with bitwise operations
I met a shell script
uva12326
2022.7.26 模拟赛
请求/响应拦截器写法