https://ac.nowcoder.com/acm/contest/5600/J
#include<iostream> using namespace std; typedef long long ll; const ll mod = 1e9+7; const int maxn = 2e5+111; int n; ll k_qll a,ll b){ ll res = 1; whileb){ ifb&1){ res = res*a)%mod; } b>>=1; a = a*a)%mod; } return res%mod; } ll jc[maxn]; ll list[maxn];//list[i]是i的阶乘 ll Cll n,ll m){ ll ans = list[n]*jc[m]*jc[n - m])%mod))%mod; return ans%mod; } ll cnt1[2000];//1 ll cnt0[2000]; int main){ scanf"%d",&n); list[0] = 1; forint i=1;i<maxn;i++){ list[i] = 1LL*list[i-1] * i)%mod; } forint i=0;i<maxn;i++){ jc[i] = k_qlist[i],mod-2)%mod; } int cns=0; forint i=0;i<n;i++){ ll x; scanf"%lld",&x); forll j=0;j<60;j++){ int t = x>>j)&1; ift) cnt1[j]++; else cnt0[j]++; } } ll sum = 0; ll ans = 0; forint i=0;i<60;i++){ ifcnt1[i] == 0) continue; ifcnt1[i]>=3){ ans = Ccnt1[i],3)*k_q2,i))%mod; sum = sum + ans)%mod; } ifcnt0[i] >= 2){ ans = Ccnt0[i],2)*cnt1[i])%mod; ans = ans*k_q2,i))%mod; sum = sum + ans)%mod; } } cout<<sum<<endl; return 0; }
寻找真正的热爱