惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
罗磊的独立博客
雷峰网
雷峰网
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
B
Blog RSS Feed
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
D
Docker
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
小众软件
小众软件
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
I
InfoQ
S
SegmentFault 最新的问题

Shiroha白羽的博客

Golang 踩坑 —— interface 为参数的时候传 nil 指针 Codeforces Round 925 (Div. 3) Codeforces Round 924 (Div. 2) Codeforces Round 923 (Div. 3) Codeforces Round 922 (Div. 2) Codeforces Round 921 (Div. 2) Educational Codeforces Round 161 (Rated for Div. 2) Codeforces Round 920 (Div. 3) Codeforces Round 919 (Div. 2) Hello 2024 Good Bye 2023 Codeforces Round 918 (Div. 4) 个人备份的常用 macOS 清理命令 Codeforces Round 917 (Div. 2) Pinely Round 3 (Div. 1 + Div. 2) Educational Codeforces Round 160 (Rated for Div. 2) Codeforces Round 915 (Div. 2) Codeforces Round 914 (Div. 2) Codeforces Round 913 (Div. 3) Educational Codeforces Round 159 (Rated for Div. 2) Codeforces Round 912 (Div. 2) Codeforces Round 911 (Div. 2) CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) Educational Codeforces Round 158 (Rated for Div. 2) Codeforces Round 910 (Div. 2) Codeforces Round 909 (Div. 3) Codeforces Round 908 (Div. 2) Educational Codeforces Round 157 (Rated for Div. 2) C++自定义的字面量 Codeforces Round 907 (Div. 2)
Codeforces Round 904 (Div. 2)
Shiroha · 2023-11-25 · via Shiroha白羽的博客

D 题有点难,数论确实不会,本着只是为了练习回复脑子的角度考虑,就不写了

A. Simple Design

大致题意

有两值,$x, k$,找到最小的 $y$ 满足 $y \geq x, y \space mod \space k = 0$

思路

因为 $k$ 很小,所以暴力枚举就行

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int x, k;
cin >> x >> k;

auto cal = [&](int x) {
int ans = 0;
while (x) {
ans += x % 10;
x /= 10;
}
return ans;
};

while (true) {
int tmp = cal(x);
if (tmp % k == 0) {
cout << x << endl;
break;
}
x++;
}
}
}

B. Haunted House

大致题意

有一个 $01$ 字符串,每次允许交换两个相邻的值,问交换多少次,就可以是 $2^i$ 的倍数(对于所有可能的 $i$)

思路

都告诉你二进制了,保证最后几个为 $0$ 的方案而已,简单模拟一下就行了

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define int long long

void solve() {
string str;
str.reserve(1e5);

int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n >> str;
int l = (int) str.size(), ans = 0;
for (int r = (int) str.size() - 1; r >= 0; --r) {
l--;
while (l >= 0 && str[l] == '1') l--;
if (l >= 0) ans += r - l;
if (l < 0) cout << -1 << ' ';
else cout << ans << ' ';
}
cout << endl;
}
}

C. Medium Design

大致题意

有一堆区间,可以选出其中一部分,对这些区间内的值 +1 问这样操作之后的区间的最大值降去最小值的最大差值可以是多少

思路

排序一下,然后遍历,因为最小值一定出现在第一个值或者最后一个值

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
vector<pair<int, int>> v;

void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, m;
cin >> n >> m;
v.resize(n);
for (auto &i: v) cin >> i.first >> i.second;

struct cmp {
bool operator()(const int &lhs, const int &rhs) const {
return v[lhs].second > v[rhs].second;
}
};

priority_queue<int, vector<int>, cmp> prq;
sort(v.begin(), v.end());

int l = 0, r = 0, cur = 0, ans = 0;
for (int i = 0; i < v.size(); ++i) {
auto &item = v[i];
prq.push(i);
cur++;
if (item.first <= 1) l++;
if (item.second >= m) r++;
while (!prq.empty()) {
if (v[prq.top()].second < item.first) {
if (v[prq.top()].first <= 1) l--;
prq.pop();
cur--;
} else break;
}
ans = max(ans, max(cur - l, cur - r));
}
cout << ans << endl;
}
}