曾经发明了脑洞治疗仪&超能粒子炮的发明家SHTSC又公开了他的新发明:超能粒子炮·改--一种可以发射威力更加
强大的粒子流的神秘装置。超能粒子炮·改相比超能粒子炮,在威力上有了本质的提升。它有三个参数n,k。它会
向编号为0到k的位置发射威力为C(n,k) mod 2333的粒子流。现在SHTSC给出了他的超能粒子炮·改的参数,让你求
其发射的粒子流的威力之和模2333。
return its inline -s desc bsp super discus esc
By 佚名上传
不说话qwq laj只是练练Lucas
- #include "bits/stdc++.h"
- using namespace std;
- typedef long long LL;
- const int mod=2333;
- LL c[mod][mod],s[mod][mod];
- inline LL read(){
- LL an=0,x=1;char c=getchar();
- while (c<‘0‘ || c>‘9‘) {if (c==‘-‘) x=-1;c=getchar();}
- while (c>=‘0‘ && c<=‘9‘) {an=(an<<3)+(an<<1)+c-‘0‘;c=getchar();}
- return an*x;
- }
- LL Lucas(LL n,LL m){
- if (n<m) return 0;
- if (n<mod && m<mod) return c[n][m];
- return Lucas(n/mod,m/mod)*Lucas(n%mod,m%mod)%mod;
- }
- LL cal(LL n,LL k)
- {
- if (k<0) return 0;
- return (cal(n/mod,k/mod-1)*s[n%mod][mod-1]+Lucas(n/mod,k/mod)*s[n%mod][k%mod])%mod;
- }
- int main(){
- freopen ("super.in","r",stdin);freopen ("super.out","w",stdout);
- int i,j;c[0][0]=s[0][0]=1;
- for (i=1;i<mod;i++) s[0][i]=1;
- for (i=1;i<mod;i++){
- c[i][0]=1,c[i][1]=i,c[i][i]=1;s[i][0]=1,s[i][1]=i+1;
- for (j=2;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
- for (j=1;j<mod;j++) s[i][j]=(s[i][j-1]+c[i][j])%mod;
- }
- LL t,n,k;
- t=read();
- while (t--){
- n=read(),k=read();
- printf("%lld\n",cal(n,k));
- }
- return 0;
- }
BZOj-4591: [Shoi2015]超能粒子炮·改 (Lucas+排列组合)
return its inline -s desc bsp super discus esc
原文:http://www.cnblogs.com/keximeiruguo/p/7812092.html
来源: http://www.bubuko.com/infodetail-2388513.html