正文
增加 11 行删除 11 行
1234547 行未改动53545556575859606167 行未改动12913013113213313413513613713813914014114214314414517 行未改动1631641651661671681691701712 行未改动17417517617717817918018118218318418518618718868 行未改动25725825926026126226326426527 行未改动2932942952962972982993003013023033043053063073083093103113123132 行未改动**状压+根号分治** ~~代码清奇可爱,一点也不毒瘤~~题目思路和代码借鉴神犇 mrsrz 的题解[题目地址](https://www.luogu.com.cn/problem/P5616)47 行未改动struct Num{char s[62];char& operator[] (int x){return s[x];}Num(int x = 1)67 行未改动more = more * ((pow2[valid[i].second] - 1ll) * valid[i].first % mod + 1) % mod;continue;}Num tmp(valid[i].first);int _2 = tmp[0];int _3 = tmp[1];int _5 = tmp[2];int _7 = tmp[3];int _o = 0;for(int i = 4 ; i < 15 ; i ++)if(tmp[i]) _o |= (1 << (i - 4));for(int _2_ = 6 ; ~_2_ ; _2_ --)for(int _3_ = 4 ; ~_3_ ; _3_ --)for(int _5_ = 2 ; ~_5_ ; _5_ --)for(int _7_ = 2 ; ~_7_ ; _7_ --)17 行未改动}ans = ans * more % mod;printf("%lld\n" , ans);exit(0);}}int main(){2 行未改动{scanf("%d" , &t);vis[t]++;max_val = max(max_val , t);}pow2[0] = 1;for(int i = 1 ; i <= n ; i ++)pow2[i] = 2*pow2[i - 1] % mod;for(int i = 1 ; i <= max_val ; i ++)if(vis[i]) valid[++tot] = make_pair(i , vis[i]);sieve();if(tot <= 18) tot_18::solve();if(max_val <= 100) maxval_100::solve();}68 行未改动return a[x[0]][x[1]][x[2]][x[3]][x[4]][x[5]][x[6]];}int calc(int x[7]) {int ans = 1;for(int i = 0 ; i < 7 ; ++i)ans = 1ll * ans * qpow(pri[i] , x[i]) % mod;return ans;}27 行未改动{int sum = qpow(2 , cnt[i]) - 1 , y[7] , z[7];memcpy(f[cur ^ 1] , f[cur] , sizeof(*f));cur ^= 1;for(int t = 0 ; t <= 1 ; ++t) ALL_NUM(x){int &from = at(f[cur ^ 1][t] , x);for(int j = 0 ; j < 7 ; ++j)y[j] = max(x[j] , pfac[i][j]) , z[j] = y[j] - x[j];int &to = at(f[cur][1] , y) , d = 1LL * calc(z) * qpow(p , t^1) % mod;to = (to + 1LL * from * d % mod * sum) % mod;}}ALL_NUM(x) {(at(f[cur][0] , x) += at(f[cur][1] , x)) %= mod;at(f[cur][1] , x) = 0;}}ALL_NUM(x) (ans += at(f[cur][0] , x)) %= mod;printf("%d\n" , ans);return 0;2 行未改动1234547 行未改动53545556575859606167 行未改动12913013113213313413513613713813914014114214314414517 行未改动1631641651661671681691701712 行未改动17417517617717817918018118218318418518618718868 行未改动25725825926026126226326426527 行未改动2932942952962972982993003013023033043053063073083093103113123132 行未改动**状压+根号分治** ~~代码清奇可爱,一点也不毒瘤~~题目思路和代码借鉴神犇 mrsrz 的题解[题目地址](https://www.luogu.com.cn/problem/P5616)47 行未改动struct Num{char s[62];char& operator[] (int x){return s[x];}Num(int x = 1)67 行未改动more = more * ((pow2[valid[i].second] - 1ll) * valid[i].first % mod + 1) % mod;continue;}Num tmp(valid[i].first);int _2 = tmp[0];int _3 = tmp[1];int _5 = tmp[2];int _7 = tmp[3];int _o = 0;for(int i = 4 ; i < 15 ; i ++)if(tmp[i]) _o |= (1 << (i - 4));for(int _2_ = 6 ; ~_2_ ; _2_ --)for(int _3_ = 4 ; ~_3_ ; _3_ --)for(int _5_ = 2 ; ~_5_ ; _5_ --)for(int _7_ = 2 ; ~_7_ ; _7_ --)17 行未改动}ans = ans * more % mod;printf("%lld\n" , ans);exit(0);}}int main(){2 行未改动{scanf("%d" , &t);vis[t]++;max_val = max(max_val , t);}pow2[0] = 1;for(int i = 1 ; i <= n ; i ++)pow2[i] = 2*pow2[i - 1] % mod;for(int i = 1 ; i <= max_val ; i ++)if(vis[i]) valid[++tot] = make_pair(i , vis[i]);sieve();if(tot <= 18) tot_18::solve();if(max_val <= 100) maxval_100::solve();}68 行未改动return a[x[0]][x[1]][x[2]][x[3]][x[4]][x[5]][x[6]];}int calc(int x[7]) {int ans = 1;for(int i = 0 ; i < 7 ; ++i)ans = 1ll * ans * qpow(pri[i] , x[i]) % mod;return ans;}27 行未改动{int sum = qpow(2 , cnt[i]) - 1 , y[7] , z[7];memcpy(f[cur ^ 1] , f[cur] , sizeof(*f));cur ^= 1;for(int t = 0 ; t <= 1 ; ++t) ALL_NUM(x){int &from = at(f[cur ^ 1][t] , x);for(int j = 0 ; j < 7 ; ++j)y[j] = max(x[j] , pfac[i][j]) , z[j] = y[j] - x[j];int &to = at(f[cur][1] , y) , d = 1LL * calc(z) * qpow(p , t^1) % mod;to = (to + 1LL * from * d % mod * sum) % mod;}}ALL_NUM(x) {(at(f[cur][0] , x) += at(f[cur][1] , x)) %= mod;at(f[cur][1] , x) = 0;}}ALL_NUM(x) (ans += at(f[cur][0] , x)) %= mod;printf("%d\n" , ans);return 0;2 行未改动