题解 | #循环数比较#

循环数比较

https://www.nowcoder.com/practice/24575008c6134b6fa4fab8ea0ea82a99?tpId=182&tqId=34530&rp=1&ru=/exam/oj&qru=/exam/oj&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26pageSize%3D50%26search%3D%26tab%3D%25E5%2590%258D%25E4%25BC%2581%25E7%259C%259F%25E9%25A2%2598%26topicId%3D182&difficulty=undefined&judgeStatus=undefined&tags=&title=

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    m = await readline();
    arr = m.split(' ');
    let arrs = new Array;
    for(let i=0; i<4; i++){
        arrs.push(parseInt(arr[i]));
    }
    var v1wei = getwei(arrs[0],0);
    var v2wei = getwei(arrs[2],0);
    var repeat1 = repeat(arr[0],arrs[1])
    let num1 = parseInt(repeat1);
    var repeat2 = repeat(arr[2],arrs[3])
    let num2 = parseInt(repeat2);
    if(v1wei*arrs[1]>v2wei*arrs[3]){
        console.log("Greater");
    }else if(v2wei*arrs[3]>v1wei*arrs[1]){
        console.log('Less');
    }else{
        if(num1>num2){
            console.log("Greater");
        }else if(num2>num1){
            console.log('Less');
        }else{
            console.log("Equal");
        }
    }
    function getwei(n,m){
        while(Math.floor(n/10)){
            n=n/10;
            m+=1;
        }
        return m+1;
    }
    function repeat(n,m){
        let str = n;
        for(let i=0; i<m-1; i++){
            str +=n;
        }
        return str;
    }   
}()

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-21 17:16
科大讯飞 算法工程师 28.0k*14.0, 百分之三十是绩效,惯例只发0.9
点赞 评论 收藏
分享
ArisRobert:统一解释一下,第4点的意思是,公司按需通知员工,没被通知到的员工是没法去上班的,所以只要没被通知到,就自动离职。就是一种比较抽象的裁员。
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务