abc238
Eva.Q Lv9

ABCDEFG ~

C

取模问题,坑死我了,呜呜呜

乘法取模问题:两个乘数分别 后,对结果再取

除法操作也需要特别注意,涉及到下取整的问题。

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
40
#include<bits/stdc++.h>
using namespace std;
#define N 377
#define mod 998244353
#define inv 499122177
typedef long long ll;

inline ll rd() {
ll x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}

inline void work() {
ll n = rd();
ll m = n;
int cnt = 0;
ll ans = 0, x = 1, t = 0;
while (n) {
n = n / 10;
cnt++;
}
for (int i = 1; i < cnt; ++i) {
t = t * 10 + 9;
if ((t - x + 1) % 2 == 0) ans = (ans + (((1 + (t - x + 1)) % mod) * (((t - x + 1) / 2) % mod))) % mod;
else ans = (ans + ((((1 + (t - x + 1)) / 2) % mod) * ((t - x + 1) % mod))) % mod;
x *= 10;
}
if ((m - x + 1) % 2 == 0) ans = (ans + (((1 + (m - x + 1)) % mod) * (((m - x + 1) / 2) % mod))) % mod;
else ans = (ans + ((((1 + (m - x + 1)) / 2) % mod) * ((m - x + 1) % mod))) % mod;
printf("%lld\n", ans);
}

int main() {
work();
return 0;
}

D

因为 ,所以, ,所以 一定要

二进制有 的位置, 对应的位置一定是

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
#include<bits/stdc++.h>
using namespace std;
#define N 377
#define mod 998244353
#define inv 499122177
typedef long long ll;

inline ll rd() {
ll x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}

inline void work() {
ll a = rd(), s = rd();
if (s < 2 * a) {puts("No"); return;}
if (s == 2 * a) {puts("Yes"); return;}
ll res = s - 2 * a;
if ((res & a) == 0) {puts("Yes"); return;}
puts("No");
}

int main() {
int t = rd();
while (t--) work();
return 0;
}

E

给的 就是知道区间和,故我们想用前缀和数组来分析这个问题。

借助图来解决这一问题,存在从 的边,就相当于知道

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
#include<bits/stdc++.h>
using namespace std;
#define N 200007
#define mod 998244353
#define inv 499122177
typedef long long ll;

vector<int> V[N];
int n, Q, vis[N];

inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}

inline void dfs(int x) {
vis[x] = 1;
for (auto i : V[x]) {
if (!vis[i]) dfs(i);
}
}

int main() {
n = rd(); Q = rd();
while (Q--) {
int u = rd() - 1, v = rd();
V[u].push_back(v); V[v].push_back(u);
}
dfs(0);
vis[n] == 1 ? puts("Yes") : puts("No");
return 0;
}
  • Post title:abc238
  • Post author:Eva.Q
  • Create time:2022-02-07 13:23:42
  • Post link:https://qyy/2022/02/07/ABC/abc238/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.