| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 39161 | LYLAKIOIAKIOI | 【S】T2 | C++ | 通过 | 100 | 31 MS | 11972 KB | 833 | 2025-12-22 20:15:51 |
#include<bits/stdc++.h> using namespace std; const int N=1e6+10,mod=1e9+7; int qp(int a,int b){ int x=1; for(;b;b>>=1,a=1ll*a*a%mod)if(b&1) x=1ll*x*a%mod; return x; } void Add(int &a,int b){a+=b;if(a>=mod) a-=mod;} int fac[N],inv[N],sum[N]; int n,m; int main(){ //freopen("life.in","r",stdin); //freopen("life.out","w",stdout); cin>>n>>m; fac[0]=1;for(int i=1;i<=m;i++) fac[i]=1ll*fac[i-1]*i%mod; inv[m]=qp(fac[m],mod-2);for(int i=m-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod; sum[0]=1;for(int i=1;i<=m;i++) sum[i]=1ll*sum[i-1]*(n-i+1)%mod; for(int i=0;i<=m;i++) sum[i]=1ll*sum[i]*inv[i]%mod; int iv=qp(n,mod-2); int ans=0; for(int i=1;i<=m;i++){ Add(ans,1ll*fac[m]*inv[m-i]%mod*sum[i]%mod*sum[i-1]%mod*iv%mod); }cout<<ans<<endl; return 0; }