找回密码
 立即注册
首页 业界区 安全 Say 题选记 (10.19 - 10.25)

Say 题选记 (10.19 - 10.25)

屋稷删 2025-10-21 23:05:01
P3702 [SDOI2017] 序列计数

首先至少 1 个质数可以容斥成随便选 - 只选合数。然后注意到第二维很小,直接矩阵快速幂即可。
Code[code]#include using namespace std;const int M = 2e7 + 5, K = 1e2 + 5, mod = 20170408;typedef long long ll;int n, m, p, pri[M], cnt;ll num[K], npri[K];bitset vis;void add(ll &x, ll y){ (x += y) %= mod;}struct matrix{        ll m[K][K];        matrix(){ memset(m, 0, sizeof(m)); }          matrix operator * (const matrix &x){                matrix ret;                for(int i = 0; i < p; ++i){                        for(int j = 0; j < p; ++j){                                for(int k = 0; k < p; ++k){                                        add(ret.m[j], m[k] * x.m[k][j]);                                }                        }                 }                 return ret;        }}a, b, f; void init(){        vis[1] = 1;        for(ll i = 2; i >= 1, a = a * a){                if(b & 1) ret = ret * a;        }        return ret;}int main(){        cin.tie(nullptr)->sync_with_stdio(0);        cin >> n >> m >> p;        init();        for(int i = 1; i > n >> q;        inv[1] = 1;        for(int i = 2; i < mod; ++i){                inv = ((mod - mod / i) * inv[mod % i]) % mod;        }        for(int i = 1; i > Op.typ;                if(Op.typ != 6){                        cin >> Op.x;                        if(Op.typ == 1) cin >> Op.k;                }        }        cin >> t;        for(int i = 1; i > x >> y;        int ans = 0;        for(int i = 1; i = 3){                b[y] -= 3;                (ret += dfs(x, y + 1)) %= mod;                b[y] += 3;        }        if(b[x] >= 1 && b[y] >= 1){                b[x]--, b[y]--;                (ret += dfs(x, y + 1)) %= mod;                b[x]++, b[y]++;        }        return ret;}int main(){        cin.tie(nullptr)->sync_with_stdio(0);        cin >> n;        for(int i = 1; i > b;        cout

相关推荐

2025-12-11 01:33:30

举报

喜欢鼓捣这些软件,现在用得少,谢谢分享!
您需要登录后才可以回帖 登录 | 立即注册