bzoj千题计划279:bzoj4591: [Shoi2015]超能粒子炮·改
2018-03-14 09:52
363 查看
http://www.lydsy.com/JudgeOnline/problem.php?id=4591
最后的式子合并同类项
最后的式子合并同类项
#include<cstdio> #include<iostream> using namespace std; typedef long long LL; const int p=2333; int C[2334][2334],s[2334][2334]; template<typename T> void read(T &x) { x=0; char c=getchar(); while(!isdigit(c)) c=getchar(); while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); } } void pre() { C[0][0]=1; for(int i=1;i<=p;++i) { C[i][0]=1; for(int j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%p; } for(int i=0;i<=p;++i) { s[i][0]=C[i][0]; for(int j=1;j<=p;++j) s[i][j]=(s[i][j-1]+C[i][j])%p; } } int Lucas(LL n,LL m) { if(n<m) return 0; int ans=1; for(;m;n/=p,m/=p) ans=ans*C[n%p][m%p]%p; return ans; } int S(LL n,LL k) { if(k<0) return 0; if(n<=p && k<=p) return s [k]; return (S(n%p,k%p)*Lucas(n/p,k/p)+S(n%p,p-1)*S(n/p,k/p-1))%p; } int main() { int T; LL n,k; pre(); read(T); while(T--) { read(n); read(k); printf("%d\n",S(n,k)); } }
相关文章推荐
- bzoj4591 [Shoi2015]超能粒子炮·改
- [BZOJ4591][SHOI2015]超能粒子炮·改(Lucas定理+数位DP)
- 【bzoj4591】[Shoi2015]超能粒子炮·改 Lucas定理
- bzoj 4591: [Shoi2015]超能粒子炮·改 [lucas定理]
- BZOJ_4591_[Shoi2015]超能粒子炮·改_Lucas定理
- 【bzoj4591】[Shoi2015]超能粒子炮·改
- 【BZOJ4591】[Shoi2015]超能粒子炮·改 Lucas定理
- [bzoj4591][Shoi2015][超能粒子炮·改] (lucas定理+组合计数)
- BZOJ 4591 【SHOI2015】 超能粒子炮·改
- Bzoj 4591: [Shoi2015]超能粒子炮·改 数论,Lucas定理,排列组合
- BZOJ4591 SHOI2015超能粒子炮·改(卢卡斯定理+数位dp)
- bzoj4591 【Shoi2015】超能粒子炮·改
- 【BZOJ4591】 SHOI2015 超能粒子炮·改
- bzoj 4591: [Shoi2015]超能粒子炮·改 Lucas定理+组合数学
- bzoj 4591 [Shoi2015]超能粒子炮·改
- 【bzoj4591】【Shoi2015超能粒子炮·改】【lucas定理】
- bzoj 4591: [Shoi2015]超能粒子炮·改 (Lucas定理)
- BZOJ4591 [Shoi2015]超能粒子炮·改
- 【SHOI2015】bzoj4591 超能粒子炮·改
- 【bzoj4591】[Shoi2015]超能粒子炮·改