# BZOJ4591: [Shoi2015]超能粒子炮·改

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

## Input

k<=n<=10^18，t<=10^5

## Output

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

1
5 5

32

## 题解Here!

$$F(n,k)=C_{n/p}^0\sum_{i=0}^{p-1}C_{n\%p}^i+C_{n/p}^1\sum_{i=0}^{p-1}C_{n\%p}^i+\cdots+C_{n/p}^{k/p}\sum_{i=0}^{k\%p}C_{n\%p}^i$$

$$\sum_{i=0}^{p-1}C_{n\%p}^i\times (C_{n/p}^0+C_{n/p}^1+...C_{n/p}^{k/p-1})$$

$$F(n\%p,p-1)\times F(n/p,k/p-1)$$

$$\sum_{i=0}^{k\%p}C_{n\%p}^i=F(n\%p,k\%p)$$

$$F(n,k)=F(n\%p,p-1)\times F(n/p,k/p-1)+C_{n/p}^{k/p}\times F(n\%p,k\%p)$$

#include<iostream>
#include<algorithm>
#include<cstdio>
#define MAXN 2510
#define MOD 2333LL
using namespace std;
long long n,k;
long long C[MAXN][MAXN],F[MAXN][MAXN];
long long date=0;char c=0;
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9'){date=date*10+c-'0';c=getchar();}
return date;
}
void make(){
int m=MAXN-10;
C[0][0]=1;
for(int i=1;i<=m;i++){
C[i][0]=C[i][i]=1;
for(int j=1;j<i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
}
for(int i=0;i<=m;i++){
F[i][0]=1;
for(int j=1;j<=m;j++)F[i][j]=(F[i][j-1]+C[i][j])%MOD;
}
}
long long Lucas(long long n,long long m){
if(n<m)return 0;
if(m==0||m==n)return 1;
if(m==1||m==n-1)return n;
return C[n%MOD][m%MOD]*Lucas(n/MOD,m/MOD)%MOD;
}
long long solve(long long n,long long k){
if(k<0)return 0;
if(n==0||k==0)return 1;
if(n<MOD&&k<MOD)return F[n][k];
return (solve(n/MOD,k/MOD-1)*F[n%MOD][MOD-1]%MOD+Lucas(n/MOD,k/MOD)*F[n%MOD][k%MOD]%MOD)%MOD;
}
int main(){