当前位置:网站首页>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))
边栏推荐
猜你喜欢
随机推荐
WebSocket implements chat function
移动应用恶意攻击激增500% 三六零天御为APP免费构建安全屏障
Jupyter shortcuts
leetcode125 验证回文串
ModuleNotFoundError: No module named 'tensorflow.keras' error message solution
Speed up your programs with bitwise operations
微信小程序用户登录auth.code2Session接口开发
Selenium: mouse, keyboard events
(2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
LeetCode 1189. “气球” 的最大数量
曲柄滑块机构运动分析和参数优化
Qt Widget project loading example of qml
Robot_Framework: keyword
可持久化线段树
Selenium: Introduction
About making a progress bar for software initialization for Qt
Power button (LeetCode) 212. The word search II (2022.07.31)
LeetCode 387. 字符串中的第一个唯一字符
Robot_Framework:关键字
Use controls as brushes to get bitmap code records