03 2022 档案
摘要:\(\text{Solution}\) 一道比较简单线段树优化$DP$,但它是黑色的!!! 一个显然的$DP$,设$f_{i,j}$表示选到第$i$个($i$必选),建了$j$个基站。 \(f_{i,j} = f_{k,j - 1} + Sw_{k,i} + C_i\) $Sw_{i,j}$表示$i
阅读全文
摘要:\(\text{Solution}\) 题目大意是求 \(\sum_{i = 1}^n [i \perp n]i^k\) 简单的推一波柿子 \(=\sum_{i = 1}^n\sum_{d|gcd(i,n)}\mu(d)i^k\) \(=\sum_{d|n}\mu(d)d^k\sum_{i = 1}
阅读全文
摘要:\(\text{Code}\) #include<cstdio> #include<map> #define LL long long using namespace std; const int M = 5e6; LL n,P,inv2,inv3,f[M + 5],tot; int vis[M +
阅读全文
摘要:\(\text{Note}\) 考虑构造函数$f$ \(f(k)=\sum_{i=1}^{n} y_i\prod_{j\neq i }\frac{k-x_j}{x_i-x_j}\) 求多项式在某一位置的取值 对于求$f(k)$,将$k$带入即可,时间复杂度为$O(n^2)$ 求多项式每一项的系数 考
阅读全文
摘要:\(\text{Solution}\) 容易发现答案为 \(\sum_{x = 1}^n\sum_{y = 1}^m[\gcd(x,y) = 1][\gcd(y,k) = 1]\) \(=\sum_{x = 1}^n\sum_{y = 1}^m\sum_{d|\gcd(x,y)}\mu(d)\sum
阅读全文
摘要:\(\text{Code}\) #include<cstdio> #include<tr1/unordered_map> #define LL long long using namespace std; const int M = 5e6; int vis[M + 5],p[M + 5],tot,
阅读全文
摘要:\(\text{Solution}\) 考虑眼切,你就$AC$了 对于求本质不同的方案数,显然可以用$Burnside$引理。 接着$DP$求方案数,对于头尾的限制,可以在最后在加一个和头部一样的珠子。用矩阵优化即可。 \(\text{Code}\) #include<cstdio> #includ
阅读全文