1 条题解
-
1
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N=1000009; const ll MOD=1000000007; ll f[N],fInv[N],inv[N]; ll dgr[N]; ll ans[N]; ll n,m; void input(){ scanf("%lld%lld",&n,&m); ll u,v; for(ll i=1;i<=m;++i){ scanf("%lld%lld",&u,&v); ++dgr[u]; ++dgr[v]; } } /* M=i*(M/i)+M%i 两边取模 0=i*(M/i)%M+M%i M%i=-i*(M/i)%M 除以i除以(M%i) inv[i]=-inv[M%i]*(M/i)%M */ void buildInv(){ inv[1]=1; for(ll i=2;i<=n;++i) inv[i]=MOD-MOD/i*inv[MOD%i]%MOD; } void buildFacInv(){ f[0]=fInv[0]=1; for(int i=1;i<=n;++i) f[i]=(f[i-1]*i)%MOD; for(int i=1;i<=n;++i) fInv[i]=fInv[i-1]*inv[i]%MOD; } ll C(ll a,ll b){ return f[a]*fInv[b]%MOD*fInv[a-b]%MOD; } void solve(){ buildInv(); buildFacInv(); for(ll u=1;u<=n;++u) for(ll k=2;k<=dgr[u];++k) (ans[k]+=C(dgr[u],k))%=MOD; ll ANS=0; for(ll k=2;k<=n-1;++k) ANS^=ans[k]; printf("%lld\n",ANS); } int main(){ freopen("bloom.in","r",stdin); freopen("bloom.out","w",stdout); input(); solve(); return 0; }
- 1
信息
- ID
- 4
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 5
- 标签
- 递交数
- 3
- 已通过
- 1
- 上传者