版本比较
FCOI 2^2^2 总结 & 题解
正文
增加 10 行删除 10 行
108 行未改动全部展开109110111112113113114115116117177 行未改动全部展开29529629729829930029930030130230330411 行未改动31631731831932032032132232332416 行未改动341342343344345345346347347348349350351207 行未改动全部展开55956056156256356356456556656722 行未改动59059159259359459459559659759839 行未改动63863964064164264264364464564645 行未改动692693694695696696108 行未改动全部展开 cin >> n >> q; while (q--) { int x, w, tot = 0; cin >> x >> w; cnt[x] += w; w = 0; cnt[x] += w; w = 0; while (x) { w += cnt[x] * (++tot); x >>= 1; }177 行未改动全部展开
#include <bits/stdc++.h>using namespace std;#define ul unsigned int#define lll unsigned __int128 const int N = 128, M = 185; #define lll unsigned __int128const int N = 128, M = 185;int init = 0;
lll f[M+2];
11 行未改动 if ((a[k] >> j) & 1u) num[j] += ((lll)(1) << k); vector<ul> b(M, 0); for (int j = 0; j < 32; j++) for (int i = 0; i < M; i++) if (num[j] >= f[M - i - 1]) { b[i] |= (1u << j); b[i] |= (1u << j); num[j] -= f[M - i - 1]; } return b;}16 行未改动## F - 列车号
很板的题以至于可以一句话题解。
我们考虑这个 $p\bmod i$,他是 $p-\lfloor \dfrac{p}{i} \rfloor i$,而看见这个 $\dfrac{p}{i}$,就不难想到整除分块,整除分块后,每一段的转移都是 $f_i=a'f_{i-1}+b'i + c'$ 的形式,直接用矩阵快速幂推到下一段即可,时间复杂度 $O(TnB^3\sqrt{p\log p})$,其中 $B=3$,表示矩阵大小。我们考虑这个 $p\bmod i$,他是 $p-\lfloor \dfrac{p}{i} \rfloor i$,而看见这个 $\dfrac{p}{i}$,就不难想到整除分块,整除分块后,每一段的转移都是 $f_i=a'f_{i-1}+b'i + c'$ 的形式,直接用矩阵快速幂推到下一段即可,时间复杂度 $O(TnB^3\sqrt{p}\log p)$,其中 $B=3$,表示矩阵大小。
如果你有耐心推式子求通项可以做到 $O(Tn\sqrt{p\log p})$,当然出题人很善良~~并且很懒~~所以没卡。如果你有耐心推式子求通项可以做到 $O(Tn\sqrt{p}\log p)$,当然出题人很善良~~并且很懒~~所以没卡。
:::info[代码]```cpp#include <bits/stdc++.h>207 行未改动全部展开 } break; } }
for (int i = 0; i < 32; ++i) { for (int k = 16; k < 32; ++k) { for (int j = 16; j < 32; ++j) { res.mt[i][j] += mt[i][k] * m.mt[k][j];22 行未改动
struct SGT { int tag[32769]; Mat res[32769];#define ls(p) (p << 1) #define ls(p) (p << 1)#define rs(p) (p << 1 | 1) inline void push_up(int i) { res[i] = res[ls(i)] * res[rs(i)]; }39 行未改动signed main() { ios::sync_with_stdio(0); cin.tie(0); int tc; cin >> tc >> n >> q >> (s + 1); memset(t.tag, 255, sizeof(t.tag));
for (int i = 0; i < 10; ++i) { for (int x = 0; x < 16; ++x) { for (int l = 0; l < 2; ++l) { for (int j = 0; j <= max(i, l * 9); ++j) {45 行未改动
- $^1$:按照洛谷颜色难度评分体系,+ / - / (空) 的后缀表示上位、下位、中位难度。- $^2$:仅在这套题目中相对而言,不过你也可以参考 CF 的评分。
所有题目均被加入了 [fishc 竞赛团副团](www.luogu.com.cn/team/87723),可以在赛后查看补题。所有题目均被加入了 [fishc 竞赛团副团](/team/87723),可以在赛后查看补题。