• + 0 comments

    JS

       function erf(x) {
            var a1 = 0.254829592;
            var a2 = -0.284496736;
            var a3 = 1.421413741;
            var a4 = -1.453152027;
            var a5 = 1.061405429;
            var p = 0.3275911;
            var sign = 1;
            if (x < 0) {
                sign = -1;
            }
            x = Math.abs(x);
            var t = 1.0 / (1.0 + p * x);
            var y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * Math.exp(-x * x);
            return sign * y;
        }
        let value = input.split(/[ \n]/g);
        let h = 100 * (1 - (0.5 * (1 + erf((parseFloat(value[2]) - parseFloat(value[0])) / (parseFloat(value[1]) * Math.sqrt(2.0))))));
        let m = 100 * (1 - (0.5 * (1 + erf((parseFloat(value[3]) - parseFloat(value[0])) / (parseFloat(value[1]) * Math.sqrt(2.0))))));
        let l = 100 * (0.5 * (1 + erf((parseFloat(value[3]) - parseFloat(value[0])) / (parseFloat(value[1]) * Math.sqrt(2.0)))));
        console.log(h.toFixed(2));
        console.log(m.toFixed(2));
        console.log(l.toFixed(2));