2024/09/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 模拟赛总结rk3,
唐氏分类讨论,赛时写了个记搜爆0了
因为
接下来分类讨论
-
假设先手取
,那么后手取 直接输,则一定先取 ,接下来先手取 又输,只能取 ,然后就会循环后手 ,先手 ,后手 ,先手 -
假设先手取
,同理接下来会循环后手 ,先手 ,后手 ,先手
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int t;
LL a, b, c;
void pr(bool pr) {
cout << (pr ? "Second" : "First") << '\n';
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
freopen("yiyi.in", "r", stdin);
freopen("yiyi.out", "w", stdout);
for (cin >> t; t; t--) {
cin >> a >> b >> c;
(a & 1) ? (pr(b ? (b - 1 <= c && c <= b + 1) : (c == 0 || c == 1))) : (pr(b == 1 ? 0 : (b ? c == 0 : c != 1)));
}
return 0;
}
赛时用了 1h 把式子推出来了,跑了
考虑打表找规律,令
当
答案为
当
答案为
当
答案为
当
答案为
到这里已经大概看出规律了,
这样就可以列出式子:
但是这样还是
证明
这是一个不严谨的证明,因为我们再次使用了找规律
考虑当时,我们展开和式:
按列相加得到,通过补项得到:
直接按式子模拟即可,注意
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL kP = 998244353;
const int kMaxN = 1e6 + 5;
LL n, f[kMaxN], ans, cnt;
LL P(LL x, LL y, LL ret = 1) {
for (; y; (y & 1) && ((ret *= x) %= kP), (x *= x) %= kP, y >>= 1) {
}
return ret;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), f[0] = 1;
freopen("wuyi.in", "r", stdin);
freopen("wuyi.out", "w", stdout);
for (int i = 1; i < kMaxN; i++) {
f[i] = f[i - 1] * i % kP;
}
cin >> n;
for (LL i = 2, tmp = 0; i <= n + 1; i++, tmp = 0) {
cnt = f[n - i + 1] * i % kP;
LL l = n - i + 1;
tmp = (P(l + 1, i - 1) - P(l, i - 1)) % kP, (tmp += kP) %= kP;
(cnt *= tmp) %= kP;
(ans += (cnt * P(f[n], kP - 2) % kP)) %= kP;
}
cout << ans << '\n';
return 0;
}
考虑前缀和,则
可以使用递归求解,令
还可以顺便记忆化一下,降低复杂度
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int kMaxN = 1e7 + 5;
int t;
LL l, r, f[kMaxN];
unordered_map<LL, LL> mp;
LL S(LL x, LL ret = 0) {
if (x <= 0) {
return 0;
}
if (mp.count(x)) {
return mp[x];
}
for (int i = 88; i; i--) {
if (x >= f[i]) {
if (x - f[i] % 2 == 0) {
ret ^= f[i];
}
return mp[x] = ret ^ S(x - f[i]) ^ S(f[i] - 1);
}
}
return 0;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), f[1] = 1, f[2] = 2;
freopen("yijiu.in", "r", stdin);
freopen("yijiu.out", "w", stdout);
for (int i = 3; i <= 88; i++) {
f[i] = f[i - 1] + f[i - 2];
}
for (cin >> t; t; t--) {
cin >> l >> r, cout << (S(r) ^ S(l - 1)) << '\n';
}
return 0;
}
比较板子的同余最短路,模数为
// BLuemoon_
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int kMaxN = 1e7 + 5, kMaxM = 3e7 + 5;
int t, n, m, a[kMaxN];
LL dis[kMaxM], ans = -1;
priority_queue<pair<LL, LL>, vector<pair<LL, LL>>, greater<pair<LL, LL>>> q;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
freopen("pear.in", "r", stdin);
freopen("pear.out", "w", stdout);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i], m = min(m, a[i]);
}
fill(dis, dis + m, 1e18);
for (q.push({0, 0}), dis[0] = 0; !q.empty();) {
auto [w, v] = q.top();
q.pop();
if (dis[v] != w) {
continue;
}
for (int i = 1; i <= n; i++) {
if (dis[(v + a[i]) % m] > dis[v] + a[i]) {
dis[(v + a[i]) % m] = dis[v] + a[i], q.push({dis[(v + a[i]) % m], (v + a[i]) % m});
}
}
}
for (int i = 0; i < m; i++) {
ans = max(ans, dis[i] - m);
}
cout << ans << '\n';
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现