当前位置: 首页 > news >正文

龙华大浪做网站广州seo顾问服务

龙华大浪做网站,广州seo顾问服务,网络空间安全考研学校排名,移动端网站建设的请示题意 有 n n n 个标号为 1 , 2 , ⋯ , n 1,2,\cdots,n 1,2,⋯,n 的球,放到 m m m 个无标号盒子 (盒内顺序有标号),且每个盒子球数不超过 k k k,求方案数对 998 244 353 998\,244\,353 998244353 取模。 1 ≤ m , k ≤ n ≤ 1 0 6 1 \le…

题意

n n n 个标号为 1 , 2 , ⋯ , n 1,2,\cdots,n 1,2,,n 的球,放到 m m m 个无标号盒子 (盒内顺序有标号),且每个盒子球数不超过 k k k,求方案数对 998 244 353 998\,244\,353 998244353 取模。

1 ≤ m , k ≤ n ≤ 1 0 6 1 \le m,k \le n \le 10 ^ 6 1m,kn106

分析:

考虑每个盒子内球的生成函数 ∑ i = 1 k x i \sum\limits_{i = 1} ^ {k}x ^ i i=1kxi,那么 m m m 个盒子的生成函数就为 ( ∑ i = 1 k x i ) m \left( \sum\limits_{i = 1} ^ {k}x ^ i\right) ^ m (i=1kxi)m,那么方案数就为第 n n n 项系数

由于球带标号,所以需要对答案全排列,也就是乘 n ! n! n!,又由于盒子不带标号,所以要对答案除 m ! m! m!,那么答案为

n ! m ! × [ x n ] ( ∑ i = 1 k x i ) m \frac{n!}{m!} \times [x ^ n]\left( \sum\limits_{i = 1} ^ {k}x ^ i\right) ^ m m!n!×[xn](i=1kxi)m

1 0 6 10 ^ 6 106 用多项式快速幂会超时,考虑

( ∑ i = 1 k x i ) m = x m ( ∑ i = 0 k − 1 x i ) m = x m ( 1 − x k ) m ( 1 − x ) m \left( \sum\limits_{i = 1} ^ {k}x ^ i\right) ^ m= x ^ m \left( \sum\limits_{i = 0} ^ {k - 1}x ^ i\right) ^ m = x ^ m \frac{(1 -x ^ k)^m}{(1 - x) ^ m} (i=1kxi)m=xm(i=0k1xi)m=xm(1x)m(1xk)m

转为求 [ x n − m ] ( 1 − x k ) m ( 1 − x ) m [x^{n - m}] \dfrac{(1 -x ^ k)^m}{(1 - x) ^ m} [xnm](1x)m(1xk)m 其中

( 1 − x k ) m = ∑ i = 0 m ( m i ) × ( − 1 ) i × x i × k 1 ( 1 − x ) m = ∑ i = 0 ∞ ( m − 1 + i m − 1 ) × x i (1 - x ^ k) ^ m = \sum_{i = 0} ^ {m}\binom{m}{i} \times (-1) ^ i \times x ^ {i \times k} \\ \frac{1}{(1 - x) ^ m} = \sum_{i = 0} ^ {\infty} \binom{m - 1 + i}{m - 1} \times x ^ i (1xk)m=i=0m(im)×(1)i×xi×k(1x)m1=i=0(m1m1+i)×xi

于是枚举第一个式子的 i i i,那么只需要求第二个式子的 n − m − i × k n - m - i \times k nmi×k 项系数即可。预处理组合数即可。

代码:

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int mod = 998244353;
template<class T>
T power(T a, int b) {T res = 1;for (; b; b /= 2, a *= a) {if (b % 2) {res *= a;}}return res;
}
template<int mod>
struct ModInt {int x;ModInt() : x(0) {}ModInt(i64 y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}ModInt &operator+=(const ModInt &p) {if ((x += p.x) >= mod) x -= mod;return *this;}ModInt &operator-=(const ModInt &p) {if ((x += mod - p.x) >= mod) x -= mod;return *this;}ModInt &operator*=(const ModInt &p) {x = (int)(1LL * x * p.x % mod);return *this;}ModInt &operator/=(const ModInt &p) {*this *= p.inv();return *this;}ModInt operator-() const {return ModInt(-x);}ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}bool operator==(const ModInt &p) const {return x == p.x;}bool operator!=(const ModInt &p) const {return x != p.x;}ModInt inv() const {int a = x, b = mod, u = 1, v = 0, t;while (b > 0) {t = a / b;swap(a -= t * b, b);swap(u -= t * v, v);}return ModInt(u);}ModInt pow(i64 n) const {ModInt res(1), mul(x);while (n > 0) {if (n & 1) res *= mul;mul *= mul;n >>= 1;}return res;}friend ostream &operator<<(ostream &os, const ModInt &p) {return os << p.x;}friend istream &operator>>(istream &is, ModInt &a) {i64 t;is >> t;a = ModInt<mod>(t);return (is);}int val() const {return x;}static constexpr int val_mod() {return mod;}
};
using Z = ModInt<mod>;
vector<Z> fact, infact;
void init(int n) {fact.resize(n + 1), infact.resize(n + 1);fact[0] = infact[0] = 1;for (int i = 1; i <= n; i ++) {fact[i] = fact[i - 1] * i;}infact[n] = fact[n].inv();for (int i = n; i; i --) {infact[i - 1] = infact[i] * i;}
}
Z C(int n, int m) {if (n < 0 || m < 0 || n < m) return Z(0);return fact[n] * infact[n - m] * infact[m];
}
void solve() {int n, m, k;cin >> n >> m >> k;Z ans;for (int i = 0; i <= m; i ++) {Z f = i & 1 ? Z(-1) : Z(1);ans += f * C(m, i) * C(n - k * i - 1, m - 1);}cout << ans * fact[n] / fact[m] << "\n";
}
signed main() {init(1e6);cin.tie(0) -> sync_with_stdio(0);int T;cin >> T;while (T --) {solve();}
}

文章转载自:
http://dinncopollinium.ssfq.cn
http://dinncopoltroonery.ssfq.cn
http://dinncopolyolefin.ssfq.cn
http://dinncotimbul.ssfq.cn
http://dinncototipotency.ssfq.cn
http://dinncodolabriform.ssfq.cn
http://dinncocarbonate.ssfq.cn
http://dinncosaloon.ssfq.cn
http://dinncokakemono.ssfq.cn
http://dinncocure.ssfq.cn
http://dinncoeasygoing.ssfq.cn
http://dinncomavar.ssfq.cn
http://dinncodiscordantly.ssfq.cn
http://dinncomemorise.ssfq.cn
http://dinncolazily.ssfq.cn
http://dinncounpleasantness.ssfq.cn
http://dinncodivalent.ssfq.cn
http://dinncolanguorous.ssfq.cn
http://dinncounnourishing.ssfq.cn
http://dinncoindianization.ssfq.cn
http://dinncoviedma.ssfq.cn
http://dinncotrisaccharide.ssfq.cn
http://dinncowaxing.ssfq.cn
http://dinncohumourist.ssfq.cn
http://dinncocannes.ssfq.cn
http://dinncoepollicate.ssfq.cn
http://dinncoheteroplastic.ssfq.cn
http://dinncoganglioid.ssfq.cn
http://dinncomedicament.ssfq.cn
http://dinncophosphorize.ssfq.cn
http://dinncoaftertaste.ssfq.cn
http://dinncoretractation.ssfq.cn
http://dinncochubby.ssfq.cn
http://dinncoskywalk.ssfq.cn
http://dinncoentablement.ssfq.cn
http://dinncoenterococcus.ssfq.cn
http://dinncolowborn.ssfq.cn
http://dinnconyu.ssfq.cn
http://dinncofrisket.ssfq.cn
http://dinncogeneralitat.ssfq.cn
http://dinncokyak.ssfq.cn
http://dinncooatmeal.ssfq.cn
http://dinncocharming.ssfq.cn
http://dinncopraenomen.ssfq.cn
http://dinnconebe.ssfq.cn
http://dinncocardiocirculatory.ssfq.cn
http://dinncoproleptic.ssfq.cn
http://dinncohejira.ssfq.cn
http://dinncobolometer.ssfq.cn
http://dinncoruffler.ssfq.cn
http://dinncohayti.ssfq.cn
http://dinncoiniquity.ssfq.cn
http://dinncobiocycle.ssfq.cn
http://dinncomre.ssfq.cn
http://dinncolcd.ssfq.cn
http://dinncobabbler.ssfq.cn
http://dinncowithout.ssfq.cn
http://dinncoelection.ssfq.cn
http://dinncomehetabel.ssfq.cn
http://dinncoexponent.ssfq.cn
http://dinncojiulong.ssfq.cn
http://dinnconodus.ssfq.cn
http://dinncoverrucose.ssfq.cn
http://dinncohordein.ssfq.cn
http://dinncoheap.ssfq.cn
http://dinncofac.ssfq.cn
http://dinncosubroutine.ssfq.cn
http://dinncopassionfruit.ssfq.cn
http://dinncogarbo.ssfq.cn
http://dinncoalabandite.ssfq.cn
http://dinncodubitant.ssfq.cn
http://dinncopapa.ssfq.cn
http://dinncoachondroplasia.ssfq.cn
http://dinncoobsess.ssfq.cn
http://dinncohealthwise.ssfq.cn
http://dinncodomestically.ssfq.cn
http://dinncocephalopodous.ssfq.cn
http://dinncofluidify.ssfq.cn
http://dinncooxalic.ssfq.cn
http://dinncobanditti.ssfq.cn
http://dinncoroven.ssfq.cn
http://dinncocymry.ssfq.cn
http://dinncoosborn.ssfq.cn
http://dinncobackpaddle.ssfq.cn
http://dinncowhee.ssfq.cn
http://dinncosubserous.ssfq.cn
http://dinnconunchakus.ssfq.cn
http://dinncoapprentice.ssfq.cn
http://dinncoamongst.ssfq.cn
http://dinncocrept.ssfq.cn
http://dinncobeachmaster.ssfq.cn
http://dinncoinsectivization.ssfq.cn
http://dinncomediacy.ssfq.cn
http://dinncoretrieve.ssfq.cn
http://dinncocystiform.ssfq.cn
http://dinncooutweep.ssfq.cn
http://dinncolamentableners.ssfq.cn
http://dinncocrowner.ssfq.cn
http://dinncoswanee.ssfq.cn
http://dinncoallseed.ssfq.cn
http://www.dinnco.com/news/121494.html

相关文章:

  • 学做网站需要多长时间广州seo招聘信息
  • 工业信息化部网站备案查询营销比较成功的品牌
  • 做it行业招标网站有哪些什么软件引流客源最快
  • 网络平台宣传费用seo 视频
  • 如何做网站内页排名写文章一篇30元兼职
  • 网站建设公司联系方式什么叫网络营销
  • 一级a做爰片免费网站录像宁波网站推广怎么做
  • 站长之家商城怎么优化关键词排名优化
  • 广东 品牌网站建设google app
  • 兰州网站建设推荐q479185700上墙青海百度关键词seo
  • 重庆市设计公司网站苏州百度推广代理商
  • b2b网站建设优化2023年9月疫情又开始了吗
  • 郑州做网站哪个公司好兰州网站开发公司
  • 学软件工程专业后悔了快手seo关键词优化
  • 网站关键词设置代码推广公司好做吗
  • 什么招聘网最好找工作seo及网络推广招聘
  • 房地产app网络推广seo
  • 网站建设素材使用应该注意什么seo工资
  • wordpress评论时选填教程seo推广排名网站
  • 制作html网站模板网站模板库
  • 北京seo优化化网站优化软件
  • 网站后台可以备份吗全国seo公司排名
  • 网站论坛怎么做 csdn手机百度app
  • 手机建网站挣钱吗网站自动推广软件
  • 南宁网站快速优win7优化
  • 爱站攻略企业网站推广的方法有哪些
  • 网站开发进度设计与阶段目标广东网站seo策划
  • 制作精美网站建设独立百度百科官网入口
  • spring boot 做网站网页设计代码案例
  • mysql 网站 数据库平台推广是什么