组合数+快速幂
#include <bits/stdc++.h> //#pragma GCC optimize("Ofast") #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <cmath> //#define double long double #define int long long #define endl '\n' using namespace std; const int N=2e5+7,M=1e1; const int INF = 0x3f3f3f3f; const int mod=1e9+7; int kmp(int a,int k,int p) { int ans=1; while (k) { if(k&1) ans=ans*a%p; k>>=1; a=a*a%p; } return ans; } // 快速幂 int fac[N]; int C(int n,int m){ if( n<m ) return 0; return fac[n]*kmp( fac[m]*fac[n-m]%mod,mod-2,mod )%mod; } // 组合数 void solve() { fac[0] = 1; for(int i=1;i<=1000;i++) fac[i] = fac[i-1]*i%mod; // 初始化 int x=C(c的下标,c的上标); cout<<x<<endl; } signed main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int T=1; cin>>T; while(T--){ solve(); } return 0; }
标签:const,组合,int,long,ans,省赛,include,模板,define From: https://www.cnblogs.com/whatdo/p/17847241.html