zoukankan      html  css  js  c++  java
  • [洛谷P1313]计算系数

    题目←

    在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;
    }
    
  • 相关阅读:
    AS3 判断双击事件
    php 数据类型转换与比较
    几行几列算法
    CCNode的属性说明
    bitmapdata的知识点
    addFrameScript用法
    TweenMax.allTo
    flash TweenMax用法
    flash流媒体资料
    c实现windows socket
  • 原文地址:https://www.cnblogs.com/loi-pingxing/p/7778911.html
Copyright © 2011-2022 走看看