[洛谷P1313]计算系数
2017-11-03 16:38
183 查看
题目←
在wwq大佬博客发现的,将数论知识点总结的很好的题
也可以用杨辉三角求组合数,不过就跟着大佬练扩欧吧……
在wwq大佬博客发现的,将数论知识点总结的很好的题
也可以用杨辉三角求组合数,不过就跟着大佬练扩欧吧……
#include<iostream> #include<cstdio> #include<algorithm> #define LL long long #define P 10007 using namespace std; const int MAXN = 20000 + 50; LL x,y; void exgcd(LL a,LL b){ if(!b){ x = 1; y = 0; return; } exgcd(b,a%b); LL tmp = y; y = x - (a/b)*y; x = tmp; } LL a,b,k,n,m,ny,xs; LL fast_pow(LL n,LL k){ if(!k)return 1; LL tmp = fast_pow(n,k >> 1)%P; if(k & 1){ return (tmp*tmp*(n%P))%P; } else return (tmp*tmp)%P; } int main(){ cin >> a >> b >> k >> n >> m; LL tmp = 1; for(int i = 1;i <= m;i ++){ tmp = (tmp*i)%P; } for(int i = 1;i <= k - m;i ++){ tmp = (tmp*i)%P; } exgcd(tmp,P); x = (x%P + P)%P; tmp = 1; for(int i = 1;i <= k;i ++){ tmp = (tmp*i)%P; } xs = (x*tmp)%P; xs = (((fast_pow(a,n)*fast_pow(b,m))%P)*xs)%P; cout << xs; }
相关文章推荐
- 洛谷 P1313 计算系数
- 洛谷P1313 计算系数【快速幂+dp】
- 数学-洛谷P1313 计算系数
- [NOIP2011] 洛谷P1313 计算系数
- 洛谷P1313 计算系数
- 洛谷 P1313 计算系数
- 洛谷 P1313 [NOIP2011 D2T1] 计算系数
- 洛谷 P1313 计算系数
- 洛谷 P1313 计算系数
- 【NOIP2011】洛谷1313 计算系数
- [洛谷 1313]计算系数---二项式定理+快速幂+逆元(费马小定理)
- P1313 计算系数
- 洛谷 1313||NOIP 2011 计算系数 二项式定理 解题报告
- 洛谷1313 计算系数
- P1313 计算系数
- P1313 计算系数
- 安装工程各种系数计算规则
- NOIP2011 计算系数 题解(超详细)
- 相关系数的计算方法
- python计算相关系数