牛客小白月赛91

1|0A-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; }

2|0B-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; }

3|0C-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; }

4|0D-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; }

5|0F-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; }

__EOF__

本文作者PHarr
本文链接https://www.cnblogs.com/PHarr/p/18175571.html
关于博主:前OIer,SMUer
版权声明CC BY-NC 4.0
声援博主:如果这篇文章对您有帮助,不妨给我点个赞
posted @   PHarr  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-05-06 AtCoder Beginner Contest 242
2023-05-06 矩阵加速递推
点击右上角即可分享
微信分享提示