• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

题目链接

#855. 异或和

给定一个长度为\(n\)的数组\(a_1,a_2,a_n\)。

请你求出下面式子的模\(1e9 7\)的值。

\[\sum_{i=1}^{n-1} \ sum _ { j=I 1}^{n}(a _ I \;XOR \;a_j)

\]

输入格式

第一行一个数字\(n\)。

接下来一行\(n\)个整数\(a_1,a_2,\dots,a_n\)。

输出格式

一行一个整数表示答案。

样例输入

3

1 2 3

样例输出

6

数据规模

所有数据保证\(2 \leq n \leq 300000,0 \leq a_i 2^{60}\)。

解题思路

思维

计算任意两个数的异或和,将每一位为\(1\) 的数的个数记录下来,然后按位计算该位的贡献

时间复杂度:\(O(60n)\)

代码

//%%%Skyqwq

#包含位/标准数据h。

//#定义int long龙

#定义帮助{ CIN。平局(空);cout.tie(空);}

#定义按钮推回

#首先定义船方不负担装货费用

#定义硒秒

#定义聚丙烯电容制造_配对

使用命名空间标准

typedef long long LL

typedef pairint,int PII;

typedef pairLL,LL PLL

template typename T bool chkMax(T x,T y) { return (y x)?x=y,1 : 0;}

模板类型名T bool chkMin(T x,T y) { return (y x)?x=y,1 : 0;}

模板类型名T void inline read(T x) {

int f=1;x=0;char s=getchar();

while(s ' 0 ' | | s ' 9 '){ if(s=='-')f=-1;s=getchar();}

while (s='9' s='0') x=x * 10 (s ^ 48),s=getchar();

x *=f;

}

const int N=3e5 5,mod=1e 9 7;

int n,a[60],res

int main()

{

求助;

桂皮酸

for(int I=1;I=n;我)

{

LL x;

cinx

for(int j=0;j60j)

a[j]=(xj1);

}

for(int I=0;i60我)

RES=(1ll * RES 1ll *(1ll Li)% mod * a% mod *(n-a)% mod)% mod;

coutres

返回0;

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now