Diary_3.12

codeforces

1.

void solve(){
    int l, r, u, d;  cin >> l >> r >> u >> d;
    if(l == r && u == d && l == u){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

2.

void solve(){
    int n;  cin >> n;
    priority_queue<int> q;
    for(int i=0; i<n; i++){
        int x;  cin >> x;
        q.push(x);
    }
    int len = n, cc;
    while(len != 1){
        cc = q.top();   q.pop();
        cc += q.top();  q.pop();
        len--;
        q.push(cc-1);
    }
    cout << q.top() << endl;
}

3.

void solve(){
    int x;  cin >> x;
    int cx = x, len = 0, tx = x;
    while(cx){
        len++;
        cx /= 2;
    }
    int mx = 1<<(len-1);
    if(x == mx || x == mx*2-1){
        cout << -1 << endl;
        return;
    }
    int c = x%2 ? x+1 : x-1;
    int y = 0, cnt = 0;
    while(c & x){
        int l = c&1;
        int r = x&1;
        c >>= 1;
        x >>= 1;
        y += (l^r)<<cnt;
        cnt++;
    }
    cout << y << endl;
}
posted @ 2025-03-12 09:09  Devpp  阅读(9)  评论(0)    收藏  举报