提交时间:2022-05-05 22:35:18
运行 ID: 49343
#include<bits/stdc++.h> using namespace std; const int M=1e9+7; int f[200005]; int Read(){ int sum=0; char ch=getchar(); while(ch<'0' || ch>'9') ch=getchar(); while(ch>='0' && ch<='9') sum=sum*10+ch-'0',ch=getchar(); return sum; } int Inv(int x,int p){ long long ans=1; while(p) { if(p & 1) ans=ans*x%M; x=x*x%M; p>>=1; } return ans%M; } int main(){ int n,m,T,x,y,ans=1; n=Read(),m=Read(),T=Read(); while(m--) x=Read(),y=Read(),++f[y]; for(int i=2;i<=n;++i) ans=ans*f[i]%M; cout<<ans<<'\n'; while(T--) { x=Read(),y=Read(); ans=ans*Inv(f[y],M-2)%M; ++f[y]; ans=ans*f[y]%M; cout<<ans<<'\n'; } return 0; }