可惜没如果=_=
时光的河入海流

4591: [Shoi2015]超能粒子炮·改

Time Limit: 10 Sec  Memory Limit: 256 MB
Submit: 960  Solved: 360
[Submit][Status][Discuss]

Description

曾经发明了脑洞治疗仪&超能粒子炮的发明家SHTSC又公开了他的新发明:超能粒子炮·改--一种可以发射威力更加
强大的粒子流的神秘装置。超能粒子炮·改相比超能粒子炮,在威力上有了本质的提升。它有三个参数n,k。它会
向编号为0到k的位置发射威力为C(n,k) mod 2333的粒子流。现在SHTSC给出了他的超能粒子炮·改的参数,让你求
其发射的粒子流的威力之和模2333。

 

Input

第一行一个整数t。表示数据组数。
之后t行,每行二个整数n,k。含义如题面描述。
k<=n<=10^18,t<=10^5

 

Output

t行每行一个整数,表示其粒子流的威力之和模2333的值。

 

Sample Input

1
5 5

Sample Output

32

HINT

 

Source

By 佚名上传

 

不说话qwq laj只是练练Lucas
 1 #include "bits/stdc++.h"
 2 using namespace std;
 3 typedef long long LL;
 4 const int mod=2333;
 5 LL c[mod][mod],s[mod][mod];
 6 inline LL read(){
 7     LL an=0,x=1;char c=getchar();
 8     while (c<'0' || c>'9') {if (c=='-') x=-1;c=getchar();}
 9     while (c>='0' && c<='9') {an=(an<<3)+(an<<1)+c-'0';c=getchar();}
10     return an*x;
11 }
12 LL Lucas(LL n,LL m){
13     if (n<m) return 0;
14     if (n<mod && m<mod) return c[n][m];
15     return Lucas(n/mod,m/mod)*Lucas(n%mod,m%mod)%mod;
16 }
17 LL cal(LL n,LL k)  
18 {  
19     if (k<0) return 0;  
20     return (cal(n/mod,k/mod-1)*s[n%mod][mod-1]+Lucas(n/mod,k/mod)*s[n%mod][k%mod])%mod;  
21 }  
22 int main(){
23     freopen ("super.in","r",stdin);freopen ("super.out","w",stdout);
24     int i,j;c[0][0]=s[0][0]=1;
25     for (i=1;i<mod;i++) s[0][i]=1;
26     for (i=1;i<mod;i++){
27         c[i][0]=1,c[i][1]=i,c[i][i]=1;s[i][0]=1,s[i][1]=i+1;
28         for (j=2;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
29         for (j=1;j<mod;j++) s[i][j]=(s[i][j-1]+c[i][j])%mod;
30     }
31     LL t,n,k;
32     t=read();
33     while (t--){
34         n=read(),k=read();
35         printf("%lld\n",cal(n,k));
36     }
37     return 0;
38 }

 

posted on 2017-11-09 23:55  珍珠鸟  阅读(178)  评论(0编辑  收藏  举报