大体思路:每一个数字对答案的贡献是 ,全部相加再对 取模就是答案,用 Lucas 定理计算组合数的取模: #include <utility> #include <cstdio> using namespace std; const int MAXN = 200005; int n; char str[MAXN]; const int C[4][4] = {{1, 0, 0}, {1, 1, 0}, {1, 2, 1}}; int lucasC(int n, int m) { if (n < 3 && m < 3) return C[n][...