牛客小白月赛91

A-Bingbong的化学世界

#include<bits/stdc++.h>

using namespace std;
const int maxn = 1001;
int a[maxn];


int main() {
    string t = "...|...";
    vector<string> x(6);
    for (auto &i: x) cin >> i;
    if (x.front() == t) {
        if (x.back() == t) cout << "p";
        else cout << "m";
    } else cout << "o";
    return 0;
}

B-Bingbong的数数世界

#include<bits/stdc++.h>

using namespace std;

void solve(){
    int n;
    cin >> n;
    if( n % 4 == 0 ) cout << "Bong\n";
    else cout << "Bing\n";
}

int main() {
    int TC;
    for (cin >> TC; TC; TC--)
        solve();
    return 0;
}

C-Bingbong的蛋仔世界

#include<bits/stdc++.h>

using namespace std;

using pii = pair<int, int>;


int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    int lx = 1, rx = n, ly = 1, ry = m, mx = n / 2 + 1, my = m / 2 + 1;
    vector<pii> a(k);
    for (auto &[x, y]: a) cin >> x >> y;
    int res = 0;
    for (int dx, dy; not a.empty();) {
        if (lx != mx) lx++, rx--;
        if (ly != my) ly++, ry--;
        vector<pii> b;
        for (const auto &[x, y]: a) {
            if (x == mx and y == my) {
                res++;
                continue;
            }
            if (x != mx and ly <= y and y <= ry) {
                if (x < mx) dx = x + 1;
                else dx = x - 1;
                if (lx <= dx and dx <= rx) b.emplace_back(dx, y);
            } else if (y != my and lx <= x and x <= rx) {
                if (y < my) dy = y + 1;
                else dy = y - 1;
                if (ly <= dy and dy <= ry) b.emplace_back(x, dy);
            }
        }

        a.swap(b);
    }
    cout << res << "\n";
    return 0;
}

D-Bingbong的奇偶世界

#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define int i64

using vi = vector<int>;

const int mod = 1e9 + 7;


int power(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = ans * x % mod;
        x = x * x % mod, y /= 2;
    }
    return ans;
}

i32 main() {
    string s;
    int n;
    cin >> n >> s;
    int res = 0;
    for (int i = 0, x, cnt = 0; i < n; i++) {
        x = s[i] - '0';
        if (x % 2 == 0) res = (res + cnt + 1) % mod;
        cnt = cnt * 2 % mod;
        if (x != 0) cnt = (cnt + 1) % mod;

    }
    cout << res << "\n";
    return 0;
}

F-Bingbong的幻想世界

做法就是进行拆位,拆位后用前后缀和统计一下每个1 可以产生多少次贡献。

#include<bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define  int long long

using vi = vector<int>;

const int mod = 1e9 + 7;

i32 main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector a(20, vi(n + 1));
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        for (int j = 0; j < 20; j++) {
            if (x & 1) a[j][i] = 1;
            x >>= 1;
        }
    }
    int res = 0;
    for (int l = 0, pre, suf; l < 20; l++) {
        pre = suf = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++)
            if (a[l][i] == 0) suf += (n - i + 1);
        for (int i = 1; i <= n; i++) {
            if (a[l][i] == 0)
                pre += i, suf -= (n - i + 1);
            else
                ans = (ans + pre * (n - i + 1) % mod + i * suf % mod) % mod;
        }
        res = (res + (1ll << l) * ans) % mod;
    }
    cout << res * 2 % mod << "\n";
    return 0;
}
posted @ 2024-05-06 18:08  PHarr  阅读(4)  评论(0编辑  收藏  举报