2024/10/23 模拟赛总结
1.2024/09/22 模拟赛总结2.2024/09/23 模拟赛总结3.2024/09/25 模拟赛总结4.2024/09/26 模拟赛总结5.2024/09/29 模拟赛总结6.2024/09/30 模拟赛总结7.2024/10/02 模拟赛总结8.2024/10/03 模拟赛总结9.2024/10/06 模拟赛总结10.2024/10/07 模拟赛总结11.2024/10/09 模拟赛总结12.2024/10/10 模拟赛总结13.2024/10/13 模拟赛总结14.2024/10/14 模拟赛总结15.2024/10/16 模拟赛总结16.2024/10/17 模拟赛总结17.2024/10/20 模拟赛总结18.2024/10/21 模拟赛总结
19.2024/10/23 模拟赛总结
-1
唐完了
把
于是可以筛出所有质数并枚举指数
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int kMaxN = 1e7 + 5;
LL a, b, ans, f[kMaxN], pr[kMaxN >> 1], tot;
bitset<kMaxN> vis;
int main() {
freopen("gcd.in", "r", stdin), freopen("gcd.out", "w", stdout);
vis[0] = vis[1] = 1;
for (int i = 2; i < kMaxN; i++) {
if (!vis[i]) {
pr[++tot] = i;
}
for (int j = 1; j <= tot && i * pr[j] < kMaxN; j++) {
vis[i * pr[j]] = 1;
if (i % pr[j] == 0) {
break;
}
}
}
fill(f, f + kMaxN, 1);
for (LL i = 1; i <= tot; i++) {
for (LL j = pr[i]; j < kMaxN; j *= pr[i]) {
f[j] = pr[i];
}
}
cin >> a >> b;
for (int i = a; i <= b; i++) {
ans += f[i];
}
cout << ans << '\n';
return 0;
}
一个简单的可行性 dp,赛时写个 01 trie
被卡到
倒序枚举每个数,其删掉任意一位后一定也可行,于是直接枚举那一位转移即可
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1e6 + 5;
int n, m, x;
bitset<kMaxN> f;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
freopen("include.in", "r", stdin), freopen("include.out", "w", stdout);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> x, f[x] = 1;
}
for (int i = kMaxN - 1; i; i--) {
if (f[i]) {
for (int j = 0; j < 20; j++) {
if (i & (1 << j)) {
f[i - (1 << j)] = 1;
}
}
}
}
for (; m; m--) {
cin >> x, cout << (f[x] ? "yes" : "no") << '\n';
}
return 0;
}
不想写高精qwq
自古 T4 出唐题,古有 原地立正
对于
否则一直往前冲,如果前面有障碍则等它升起再走,否则原地不动,如果当前闸门降下也不管,就呆着,不输出 -1
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1e5 + 2;
int n, m, ans;
vector<pair<int, int>> f[kMaxN];
unordered_map<int, int> b[kMaxN];
void DFS(int x, int t) {
if (ans) {
return;
}
if (x > n) {
ans = t;
return;
}
if (b[x + 1][t + 1] == 0) {
DFS(x + 1, t + 1);
}
if (b[x][t + 1] == 0) {
DFS(x, t + 1);
}
if (x && b[x - 1][t + 1] == 0) {
DFS(x - 1, t + 1);
}
}
void Solve() {
for (int i = 1, x, y, z; i <= m; i++) {
cin >> x >> y >> z;
for (int j = y; j <= z; j++) b[x][j] = y;
}
DFS(0, 0), cout << ans << '\n', exit(0);
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
freopen("move.in", "r", stdin), freopen("move.out", "w", stdout);
cin >> n >> m;
(n <= 10 && (Solve(), 0)), ans = 1;
for (int i = 1, x, y, z; i <= m; i++) {
cin >> x >> y >> z, f[x].push_back({y, z});
}
for (int i = 1; i <= n; i++, ans++) {
for (auto [x, y] : f[i]) {
if (ans < x) {
break;
} else if (ans > y) {
continue;
} else {
ans = y + 1;
}
}
}
cout << ans << '\n';
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现