头像

RainSure

河北大学网络空间安全与计算机学院 计算机科学与技术专业




离线:1小时前


最近来访(519)
用户头像
hhhhkk
用户头像
刘六六
用户头像
冰之韵
用户头像
Moon_2
用户头像
喧豗灬
用户头像
冰冰糖葫芦
用户头像
往事随风_
用户头像
小飞不会起名字
用户头像
20164436
用户头像
宇宙无敌大帅哥
用户头像
BT7274
用户头像
手可摘太阳
用户头像
Jerry_71
用户头像
LittleGoose
用户头像
等等
用户头像
自律
用户头像
ycx_yyds
用户头像
First
用户头像
liuzhexuan
用户头像
roserabbit

活动打卡代码 AcWing 805. x和y的最大值

let buf = "";

process.stdin.on('readable', function(){
    let chunk = process.stdin.read();
    if(chunk) buf += chunk.toString();
});

function max(x, y){
    if(x >= y) return x;
    return y;
}

process.stdin.on('end', function(){
    let [a, b] = buf.split('\n')[0].split(' ').map(function(x){return parseInt(x);});
    console.log(max(a, b));
})


活动打卡代码 AcWing 813. 打印矩阵

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

function print(a, row, col){
    for(let i = 0; i < row; i ++){
        let line = "";
        for(let j = 0; j < col; j ++){
            line += `${a[i][j]} `;
        }
        console.log(line);
    }
}

process.stdin.on('end', function(){
    let lines = buf.split('\n');
    let [n, m] = lines[0].split(' ').map(function(x) {return parseInt(x); });
    let a = [];
    for(let i = 0; i < n; i ++){
        a.push(lines[i + 1].split(' ').map(function(x){return parseInt(x);}));
    }
    print(a, n, m);
})


活动打卡代码 AcWing 808. 最大公约数

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

function gcd(a, b){
    return b ? gcd(b, a % b) : a;
}

process.stdin.on('end', function(){
   let [a, b] = buf.split('\n')[0].split(' ').map(function(x){return parseInt(x);});
   console.log(gcd(a, b));
});


活动打卡代码 AcWing 818. 数组排序

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

function bubble_sort(q, l, r) {
    for (let i = r; i > l; i -- ) {
        for (let j = l; j < i; j ++ ) {
            if (q[j] > q[j + 1]) {
                [q[j], q[j + 1]] = [q[j + 1], q[j]];
            }
        }
    }
}

process.stdin.on('end', function(){
    let lines = buf.split('\n');
    let [n, l, r] = lines[0].split(' ').map(function(x){return parseInt(x);});
    let q = lines[1].split(' ').map(function(x){return parseInt(x);});
    bubble_sort(q, l, r);
    console.log(q.join(' '));
});


活动打卡代码 AcWing 823. 排列

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});
let path = [];
let st = [];
function dfs(u, n) {
    if(u == n) console.log(path.join(' '));
    else{
        for(let i = 1; i <= n; i ++){
            if(!st[i]){
                st[i] = true;
                path.push(i);
                dfs(u + 1, n);
                st[i] = undefined;
                path.pop();
            }
        }
    }
}

process.stdin.on('end', function(){
    let n = parseInt(buf);
    dfs(0, n);
})



let buf = "";

function reverse(str){
    return str.split('').reverse().join('');
}

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

process.stdin.on('end', function(){
   let lines = buf.split('\n');
   for(let i = 0; i < lines.length; ){
       let n = parseInt(lines[i]);
       i ++;
       if(n === 0) break;
       for(let j = 0; j < n; j ++){
           lines[i + j] = reverse(lines[i + j]);
       }
       let res = "";
       for(let k = 0; k < lines[i].length; k ++){
           let is_same = true;
           for(let j = 1; j < n; j ++){
               if(lines[i + j][k] != lines[i][k]){
                   is_same = false;
                   break;
               }
           }
           if(is_same) res += lines[i][k];
           else break;
       }
       i += n;
       console.log(reverse(res));
   }
});


活动打卡代码 AcWing 775. 倒排单词

let buf = '';

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

process.stdin.on('end', function(){
    let vals = buf.split('\n')[0].split(' ');
    let res = "";
    for(let i = vals.length - 1; i >= 0; i --){
        res += vals[i];
        if(i != 0) res += ' ';
    }
    console.log(res);
});


活动打卡代码 AcWing 770. 单词替换

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

process.stdin.on('end', function(){
   let lines = buf.split('\n');
   let a = lines[1], b = lines[2];
   let vals = lines[0].split(' ');
   for(let i = 0; i < vals.length; i ++){
       if(vals[i] === a) vals[i] = b;
   }
   let res = "";
   for(let i = 0; i < vals.length; i ++){
       res += `${vals[i]} `;
   }
   console.log(res);
});



let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

process.stdin.on('end', function(){
   let str = buf.split('\n')[0];
   let num = {};
   for(let i = 0; i < str.length; i ++) {
       if(str[i] in num) num[str[i]] ++;
       else num[str[i]] = 1;
   }
   for(let i = 0; i < str.length; i ++) {
       if(num[str[i]] === 1){
           console.log(str[i]);
           return;
       }
   }
   console.log("no");
});


活动打卡代码 AcWing 760. 字符串长度

let buf = "";

process.stdin.on('readable', function(){
   let chunk = process.stdin.read();
   if(chunk) buf += chunk.toString();
});

process.stdin.on('end', function(){
   let str = buf.split('\n')[0];
   console.log(str.length);
});