头像

笨蛋1




离线:5小时前


最近来访(155)
用户头像
候默
用户头像
ycf_gogogo
用户头像
彭明陶
用户头像
eric_f
用户头像
yxc
用户头像
Mhbfy
用户头像
bline
用户头像
ღSupperღ
用户头像
che_che
用户头像
emoemo
用户头像
L2ncE
用户头像
种花家的兔兔
用户头像
bxy
用户头像
kelvin2009
用户头像
史一帆
用户头像
ζ..懒灬猫①
用户头像
谷谷
用户头像
ゞ正在缓冲99_21
用户头像
山山而川_93
用户头像
小鱼.

活动打卡代码 AcWing 4619. 减法操作

笨蛋1
5天前
#include<iostream>

using namespace std;

const int N = 2e5+10;

int a[N];
int n;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }
    for(int i = 1; i < n; i ++)
    {
        if(a[i] & 1)
        {
            a[i]--;
            if(a[i+1] == 0)
            {
                puts("NO");
                return 0;
            }
            a[i+1]--;
        }
    }
    if(a[n]&1)
    {
        puts("NO");
    }
    else
    {
        puts("YES");
    }
}


活动打卡代码 AcWing 4618. 两个素数

笨蛋1
5天前
#include<iostream>
using namespace std;

int main()
{
    int x;
    int a, b;
    cin >> x;
    for(int i = 2; i <= x / i; i ++)
    {
        if(x % i == 0)
        {
            a = i, b = x / i;
            bool st1 = false, st2 = false;
            for(int j = 2; j <= a / j; j ++)
                if(a % j == 0) st1 = true;
            for(int j = 2; j <= b / j; j ++)
                if(b % j == 0) st2 = true;
            if(st1 || st2) continue;
            else
            {
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
}


活动打卡代码 AcWing 823. 排列

笨蛋1
10天前
let buf = "";

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

let path = [];
let st = [];

let dfs = function(u, n){
    if(u === n){
        console.log(path.join(' '));
        return ;
    }
    for(let i = 1; i <= n; i ++) {
        if(st[i] === 1) continue;
        path[u] = i;
        st[i] = 1;
        dfs(u+1, n);
        st[i] = 0;
    }
}

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

});


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

笨蛋1
10天前
let buf = "";

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

let sort = function(num, l, r){
    for(let i = l; i <= r; i ++){
        for(let j = i + 1; j <= r; j ++){
            if(num[i] > num[j]){
                let t = num[i];
                num[i] = num[j];
                num[j] = t;
            }
        }
    }
}

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


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

笨蛋1
10天前
let buf = "";

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

let gcd = function(a, b){
    if(a % b === 0) return b;
    else return gcd(b, a % b);
}

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


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

笨蛋1
10天前
let buf = "";

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

// let print2D = function(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);
//     }
// }

let print2D = function(a, row, col) {
    for(let i = 0; i < row; i ++){
        console.log(a[i].join(' '));
    }
}

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


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

笨蛋1
10天前
let buf = "";

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

let max = function (a, b){
    if(a > b){
        return a;
    } else {
        return b;
    }
}

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



笨蛋1
10天前
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 cnt = 0;
    while(1){
        let n = parseInt(lines[cnt]);
        cnt ++;
        if(n === 0) return ;
        let s = [];
        let minv = 999;
        for(let i = 0; i < n; i ++){
            s[i] = lines[cnt];
            cnt ++;
            minv = Math.min(minv, s[i].length);
        }
        if(n === 1){
            console.log(s[0]);
            continue;
        }
        let last = 1, st = 0;
        for(let i = 1; i <= minv; i ++){
            for(let j = 1; j < n; j ++){
                if(s[j][s[j].length-i] != s[j-1][s[j-1].length-i]){
                    last = i - 1;
                    st = 1;
                    break;
                }
                last = i;
            } if(st === 1){
                break;
            }
        }
        let line = "";
        for(let i = s[0].length - last; i < s[0].length; i ++){
            line += s[0][i];
        }
        console.log(line);
    }
});


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

笨蛋1
10天前
let buf = "";

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

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


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

笨蛋1
10天前
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 str = lines[0].split(' ');
    let line = "";
    for(let c of str){
        if(c == lines[1]){
            line += lines[2];
        } else {
            line += c;
        }
        line += ' ';
    }
    console.log(line);
});