【JZOJ 4786】小a的强迫症
来源:互联网 发布:js数组增加一个元素 编辑:程序博客网 时间:2024/06/02 13:00
Description
Solution
从后往前做,很显然当前颜色做完以后就可以直接全部删掉,
直接用C公式即可。
复杂度:
Code
#include<cstdio>#define fo(i,a,b) for(int i=a;i<=b;i++)#define fod(i,a,b) for(int i=a;i>=b;i--)using namespace std;typedef long long LL;const int N=100500,mo=998244353;int read(int &n){ char ch=' ';int q=0,w=1; for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar()); if(ch=='-')w=-1,ch=getchar(); for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;}int n,m;int a[N];LL jc[N*5],jcn[N*5],ans;LL ksm(LL q,LL w){ LL ans=1; while(w) { if(w&1)ans=(ans*q)%mo; q=(q*q)%mo;w>>=1; } return ans;}LL C(int n,int m){return jc[m]*jcn[n]%mo*jcn[m-n]%mo;}int main(){ int q,w; read(n); fo(i,1,n)m+=read(a[i]); jc[0]=jcn[0]=1; fo(i,1,m)jc[i]=jc[i-1]*i%mo,jcn[i]=ksm(jc[i],mo-2); ans=1; fod(i,n,1)ans=(ans*C(a[i]-1,m-1))%mo,m-=a[i]; printf("%lld\n",ans); return 0;}
0 0
- 【JZOJ 4786】 小a的强迫症
- 【JZOJ 4786】小a的强迫症
- JZOJ 4786. 小a的强迫症
- JZOJ 4786 【NOIP2016提高A组模拟9.17】小a的强迫症
- JZOJ 4786. 【NOIP2016提高A组模拟9.17】小a的强迫症
- 【jzoj4786】【小a的强迫症】
- [JZOJ4786] 小a的强迫症
- 【JZOJ4786】小a的强迫症
- 【NOIP模拟】小a的强迫症
- Jzoj4786 小a的强迫症
- NOIP提高组【JZOJ4786】小a的强迫症
- 【NOIP2016提高A组模拟9.17】小a的强迫症
- 【NOIP2016提高A组模拟9.17】小a的强迫症
- JZOJ4786. 【NOIP2016提高A组模拟9.17】小a的强迫症
- 【JZOJ4786】【NOIP2016提高A组模拟9.17】小a的强迫症
- #1473 : 小Ho的强迫症
- [Offer收割]编程练习赛8 A 小Ho的强迫症
- jzoj 3583. 【GDOI2014模拟】小A的树
- 198. House Robber
- 透视投影的原理和实现
- 荣华小学访问
- lightoj 1145 - Dice (I)
- 1.适配器模式
- 【JZOJ 4786】小a的强迫症
- Xcode8.0 更新之后遇到的那些坑 实时更新
- IOS OpenGLES2.0 入门01 清空屏幕
- UE4成批处理透明材质
- 单元测试系列一:单元测试之道
- 决策树Decision Tree
- 乡村走访
- 【Bash百宝箱】shell内建命令之break与continue
- 用户管理(4)---chage、whoami