标签:lucas定理 www dig main signed 运用 end clu 运算
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define U(i,u) for(register int i=head[u];i;i=nxt[i])
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define per(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> PII;
typedef vector<int> VI;
template<class T> inline void read(T &x){
x=0;char c=getchar();int f=1;
while(!isdigit(c)){if(c==‘-‘)f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-‘0‘;c=getchar();}x*=f;
}
template<class T> inline void cmin(T &x, T y){x=x<y?x:y;}
template<class T> inline void cmax(T &x, T y){x=x>y?x:y;}
const int N=1001;
const int P=10007;
int qpow(int a,int b){
int res=1;for(;b;b>>=1){
if(b&1)res=1LL*res*a%P;
a=1LL*a*a%P;
}
return res%P;
}
int a,b,k,n,m,c[N][N];
int C(int n,int m){
if(m==1)return n%P;
if(!m)return 1;
int tmp=0;
if(c[n-1][m-1])(tmp+=c[n-1][m-1])%=P;else (tmp+=c[n-1][m-1]=C(n-1,m-1))%=P;
if(n>m){if(c[n-1][m])(tmp+=c[n-1][m])%=P;else (tmp+=c[n-1][m]=C(n-1,m))%=P;}
return tmp%P;
}
int main(){
read(a);read(b);read(k);read(n);read(m);
printf("%lld",1LL*C(k,n)*qpow(a,n)*qpow(b,k-n)%P);
return 0;
}
标签:lucas定理 www dig main signed 运用 end clu 运算
原文地址:https://www.cnblogs.com/hangzz/p/13377928.html