总结
- 被edu撅飞力
- 只会前三题,掉绿指日可待
- 我这种彩笔还是不适合div.2
A
直接模拟,注意细节
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll p[15] = {1};
void solve() {
ll x;
cin >> x;
int len = 0;
while(x / p[len + 1]) ++ len;
for(int i = 1; i <= len; ++ i) {
ll a = x / p[i];
ll b = x % p[i];
if(b >= p[i - 1] && b > a) {
return cout << a << ' ' << b << '\n', void();
}
}
cout << "-1\n";
}
int main() {
for(int i = 1; i <= 10; ++ i) p[i] = p[i - 1] * 10;
int T;
cin >> T;
while(T --) solve();
return 0;
}
B
一道很直观的贪心,用现有的0和1去构造答案,一旦失败,输出答案
```
include<bits/stdc++.h>
using namespace std;
void solve() {
string s;
cin >> s;
int cnt[2] = {0, 0};
for(auto ch : s) cnt[1] += ch == '1', cnt[0] += ch == '0';
for(int i = 0; i < s.length(); ++ i) {
if(s[i] == '0') {
if(-- cnt[1] < 0) return cout << s.length() - i << '\n', void();
}
else if(-- cnt[0] < 0) {
return cout << s.length() - i << '\n', void();
}
}
cout << "0\n";
}
int main() {
ios :: sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int T;
cin >> T;
while(T --) solve();
return 0;
}
```
C
开一个\(f\)数组统计某一位出现的次数
注意第\(i\)位能被两个\(i - 1\)位合成
检验时从低到高位遍历,同时计算\(f\)数组内部低位对高位的贡献
#include<bits/stdc++.h>
using namespace std;
int f[40], g[40];
bool check(int x) {
memcpy(g, f, sizeof f);
for(int i = 0; i <= 30; ++ i) {
if(x >> i & 1) {
if(g[i]) {
g[i + 1] += (g[i] - 1) / 2;
}
else return 0;
}
else g[i + 1] += g[i] / 2;
}
return 1;
}
int main() {
ios :: sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int m;
cin >> m;
while(m --) {
int op, x;
cin >> op >> x;
if(op == 1) ++ f[x];
else {
cout << (check(x) ? "YES" : "NO") << '\n';
}
}
return 0;
}
- Educational Codeforces Round 160educational codeforces round 160 educational codeforces round rated educational codeforces round 151 construction educational codeforces round educational codeforces round 147 cf-educational educational codeforces round educational codeforces round 158 educational codeforces contest round educational codeforces monsters round educational codeforces balance round