牛客小白月赛91 (小白被虐记)

youhualiuh / 2024-04-20 / 原文

A.Bingbong的化学世界(签到题)

思路:

 你会发现当 a[1][4] == '.' 是是 o-甲乙苯  a[6][4] == '|' 是是 p-甲乙苯 另外则是m-甲乙苯 

Code:

#include<bits/stdc++.h>
    
using namespace std;
    
const int N = 10;

char a[N][N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    for (int i = 1; i <= 6; i++) for (int j = 1; j <= 7; j++) {
        cin >> a[i][j];
    }

    if (a[1][4] == '.') cout << 'o';
    else if (a[6][4] == '|') cout << 'p';
    else cout << 'm';

    return 0;
}

B.Bingbong的数数世界

思路:

如果存在对方的数应该都选择删除 后者如果想赢 则最后刚好是两even 两odd进行判断即可

Code:

#include<bits/stdc++.h>
    
using namespace std; 

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T; cin >> T;
    while (T--) {
        int n; cin >> n;
        cout << (n % 4 != 0 ? "Bing\n" : "Bong\n");
    }    
    return 0;
}

C.Bingbong的蛋仔世界

思路:

曼哈顿距离 只要小于我达到中心的距离即可

Code:

#include<bits/stdc++.h>
    
using namespace std; 

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m, k; cin >> n >> m >> k;
    int dx = n / 2 + 1, dy = m / 2 + 1, cnt = 0;
    while (k --) {
        int x, y; cin >> x >> y;
        int dir = abs(x - dx) + abs(y - dy);
        if (dir <= max(dx - 1, dy - 1)) cnt ++;
    }
    cout << cnt << '\n';
    return 0;
}

D.Bingbong的奇偶世界

思路:

如果当前是0 则以0后导 不过不能作为前导 则{
    ans = ans + cnt + 1;
    cnt *= 2;
}

如果是奇数 它可以接在任意数的前后 不过不是满足的答案 {
    cnt *= 2;
}

如果是偶数 它可以放在任意数字的后面 {
    ans = ans + cnt + 1;
    cnt *= 2;
}

  

Code:

#include<bits/stdc++.h>
    
using namespace std;
    
const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n; string s; cin >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        int x = s[i] - '0';
        if (!x) {
            ans += cnt + 1;
            cnt = cnt * 2;
        }
        else if (x & 1) {
            cnt = cnt * 2 + 1;
        }
        else {
            ans += cnt + 1;
            cnt = cnt * 2 + 1;
        }
        cnt %= mod; ans %= mod;
    }
    cout << ans << '\n';
    return 0;
}