zoukankan      html  css  js  c++  java
  • 2016"百度之星"

    1003.杨辉三角+逆元

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <stack>
    #include <string>
    #include <queue>
    #include <vector>
    #include <algorithm>
    #include <ctime>
    using namespace std;
    
    //#define EdsonLin
    
    #ifdef EdsonLin
    #define debug(...) fprintf(stderr,__VA_ARGS__)
    #else
    #define debug(...)
    #endif // EdsonLin
    
    typedef long long ll;
    
    const ll inf = (1ll)<<60;
    const int MAXN = 2e5+10;
    const ll MOD = 1000000007;
    
    
    
    ll fac[MAXN],ifac[MAXN];
    
    ll qp(ll base,ll n){
        ll ans = 1;
        while(n){
            if(n&1)ans = ans*base%MOD;
            n /= 2;
            base = base*base%MOD;
        }
        return ans;
    }
    
    void init(){
        fac[0] = 1;
        for(int i=1;i<MAXN;i++)
            fac[i] = fac[i-1]*i%MOD;
        for(int i=0;i<MAXN;i++)
            ifac[i] = qp(fac[i],MOD-2);
    }
    
    int main(){
        #ifdef EdsonLin
        //freopen("1.in","r",stdin);
        //freopen("1.out","w",stdout);
        int _time_jc = clock();
        #endif // EdsonLin
        init();
        int n,m;
        while(cin>>n>>m){
            if(n<m)swap(n,m);
            n = m+n-4;
            m -= 2;
            ll ans = fac[n]%MOD*ifac[m]%MOD*ifac[n-m]%MOD;
            printf("%lld
    ",ans);
        }
        #ifdef EdsonLin
            debug("time: %d
    ",int(clock()-_time_jc));
        #endif // EdsonLin
    
        return 0;
    }
    View Code
    在一个谎言的国度,沉默就是英雄
  • 相关阅读:
    AD中各层的说明
    Altium designer的PCB设计规则
    python 的基础 学习 第三天 编码的初始
    python 的基础 学习 第三
    python的基础初始第二天
    python 的基础 学习 第一天
    Liunx ls命令
    Liunx cd命令
    CentOS 7系统关闭yum自动下载更新
    【转】XenServer体系架构解析
  • 原文地址:https://www.cnblogs.com/EdsonLin/p/5518405.html
Copyright © 2011-2022 走看看