AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 问答
  • 吐槽
  • 登录/注册

AcWing 211. 计算系数

作者: 作者的头像   asdypeij ,  2022-09-06 21:16:04 ,  所有人可见 ,  阅读 5


0


// Problem: P1313 [NOIP2011 提高组] 计算系数
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1313
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
#define F(i,j,k) for (signed i=signed(j);i<=signed(k);i++)
#define endl '\n'
#define int long long
const int mod=10007;

int a,b,k,n,m;
int qPow(int a,int b){
    int ans=1;
    while(b){
        if(b%2) (ans*=a)%=mod;
        (a*=a)%=mod,b/=2;
    }
    return ans;
}
int inv(int x){return qPow(x,mod-2);}
int P(int a,int b){//从b个数中选a个数的个数
    int ans=1;
    for(int i=b,j=1;j<=a;i--,j++) (ans*=i)%=mod;
    return ans;
}
int fac(int x){return x==1?1:x*fac(x-1)%mod;}

signed main() { 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b>>k>>n>>m;
    cout<<qPow(a,n)*qPow(b,m)%mod*P(n,k)%mod*inv(fac(n))%mod<<endl;
    return 0; 
}






0 评论

你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息