把每个数字每一位上二进制数字取出,求答案时直接用N个数里这一位是0的个数乘上这一位是1的个数然后乘上二的这一位次方,注意所有可能溢出的地方都要对mod取模。

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
long long a[];
int num[][];
long long sum0[],sum1[],presolve[];
const long long mod = 1e9+;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
for(int i=;i<=n;++i)
cin>>a[i];
for(int i=;i<=n;++i){
long long temp=a[i];
int cnt=;
while(temp){
if(temp&)
num[i][cnt]=;
++cnt;
temp/=;
}
}
long long ans=;
for(int i=;i<=n;++i){
for(int k=;k<=;++k){
if(num[i][k]==)
++sum0[k];
else
++sum1[k];
}
}
long long x=;
presolve[]=;
for(int i=;i<=;++i){
x*=;
presolve[i]=x;
}
for(int i=;i<=;++i){
ans+=(((sum0[i]*sum1[i])%mod)*(presolve[i]%mod))%mod;
ans%=mod;
}
cout<<ans;
return ;
}

Atcoder Beginner Contest 147D(按位处理)的更多相关文章

  1. AtCoder Beginner Contest 261E // 按位思考 + dp

    题目链接:E - Many Operations (atcoder.jp) 题意: 给定一个数x,以及n个操作(ti,ai): 当 t = 1 时,将 x & a 当 t = 2 时,将 x ...

  2. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  3. AtCoder Beginner Contest 154 题解

    人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...

  4. AtCoder Beginner Contest 153 题解

    目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...

  5. AtCoder Beginner Contest 161

    比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于 ...

  6. AtCoder Beginner Contest 223

    AtCoder Beginner Contest 223 A是纯纯的水题,就不说了 B - String Shifting 思路分析 我真的sb,一开始想了好久是不是和全排列有关,然后读了好几遍题目也 ...

  7. KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解

    KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解 哦淦我已经菜到被ABC吊打了. A - Century 首先把当前年 ...

  8. AtCoder Beginner Contest 173 题解

    AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...

  9. AtCoder Beginner Contest 172 题解

    AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...

随机推荐

  1. C#调用WSDL接口

    http://www.cnblogs.com/wlming/p/8032782.html

  2. BK: Data mining, Chapter 2 - getting to know your data

    Why: real-world data are typically noisy, enormous in volume, and may originate from a hodgepodge of ...

  3. a标签绑定事件

    <a href="javascript:void(0);" onclick="js_method()"></a> 这种方法是很多网站最常 ...

  4. Hibernate的save方法不能进行数据库插入

    问题描述 在 MyEcplise 上运行 tomcat,利用 po 模板自动生成 po 文件,调用 po 的 save 方法,不报错,但是无法把数据插入数据库 applicationContext.x ...

  5. Python里的Flask开发环境的搭建

    在已经安装好了Python后,我这里用的是Python3.5,准备进一步学习Flask框架,下面记录搭建Flask环境 这里使用了虚拟环境,在虚拟环境里,最小化的安装Flask. 参考步骤: 1.首先 ...

  6. Docker最全教程——从理论到实战(十)

    终于按时完成第二篇.本来准备着手讲一些实践,但是数据库部分没有讲到,部分实践会存在一些问题,于是就有了此篇以及后续——数据库容器化.本篇将从SQL Server容器化实践开始,并逐步讲解其他数据库的容 ...

  7. 超简单的OpenGL & WebGL & Three.js介绍_1

    专业解释 什么是OpenGL OpenGL(Open Graphics Library即开放图形库或者“开放式图形库”)是用于渲染2D.3D矢量图形的跨语言.跨平台的应用程序编程接口(API). 这个 ...

  8. C# 读取webConfig配置

    获取百度URL  var url = System.Configuration.ConfigurationManager.AppSettings["BaiduUrl"]; < ...

  9. OpenGL 编程指南 (3.2)

    1.帧缓冲对象 帧缓冲对象对于离屏渲染.纹理贴图更新.缓存乒乓技术(buffer ping-pongqing,GPGPU的一种数据传输方式)的实现意义非凡,它减少了大量的数据拷贝工作. 建立帧缓冲需要 ...

  10. 随机数模块random_python

    一.随机数模块random 1.常用的几个方法: import randomprint(random.random()) #(0,1)之间的随机数字,如0.6772275352932792print( ...