标签:机器 html end wap using nod while .com pac
题目链接: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1119
转化成杨辉三角就好辣@_@
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL mod=1e9+7; const LL M=2e6; LL fac[M+5]; //阶乘 LL inv_of_fac[M+5]; //阶乘的逆元 LL qpow(LL x,LL n) { LL ret=1; for(; n; n>>=1) { if(n&1) ret=ret*x%mod; x=x*x%mod; } return ret; } void init() { fac[0]=1; for(int i=1; i<=M; i++) fac[i]=fac[i-1]*i%mod; inv_of_fac[M]=qpow(fac[M],mod-2); for(int i=M-1; i>=0; i--) inv_of_fac[i]=inv_of_fac[i+1]*(i+1)%mod; } LL C(LL a,LL b) { if(b<0||a<b) return 0; return fac[a]*inv_of_fac[b]%mod*inv_of_fac[a-b]%mod; } int main() { init(); int n,m; while(cin>>n>>m) { if(n<m) swap(n,m); cout<<C(n+m-2,m-1)<<endl; } }
标签:机器 html end wap using nod while .com pac
原文地址:http://www.cnblogs.com/Just--Do--It/p/6402582.html