实际上函数值为x&(-y)

答案仅和第一个数字放谁有关

 #define HAVE_STRUCT_TIMESPEC
#include <bits/stdc++.h>
using namespace std;
int a[];
int b[][];
int flag[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int start=;
int mx=;
for(int i=;i<=n;++i){
cin>>a[i];
int temp=a[i];
while(temp){
b[i][++b[i][]]=temp%;//转化为二进制
temp>>=;
}
for(int j=;j<=b[i][];++j)
if(b[i][j]!=)
++flag[j];//记录有多少数字这一位上是1
a[n+i]=a[i];
}
for(int i=;i<=n;++i){
int he=;
for(int j=;j<=b[i][];++j)
if(b[i][j]&&flag[j]==)//如果仅有a[i]这一位上为1,那么它放在顺序的第一个时可以为总和做出1<<(j-1)的贡献
he|=(1ll<<(j-));
if(he>mx){//更新最大值
mx=he;
start=i;
}
}
for(int i=start;i<=n-+start;++i)
cout<<a[i]<<" ";
return ;
}

Codeforces Round #618 (Div. 1)A(观察规律)的更多相关文章

  1. Codeforces Round #618 (Div. 1)B(几何,观察规律)

    观察猜测这个图形是中心对称图形是则YES,否则NO #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace ...

  2. Codeforces Round #242 (Div. 2)C(找规律,异或运算)

    一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典 ...

  3. Codeforces Round #618 (Div. 2)

    题库链接 https://codeforces.ml/contest/1300 A. Non-zero 一个数组,每次操作可以给某个数加1,让这个数组的积和和不为0的最小操作数 显然如果有0的话,必须 ...

  4. [CF百场计划]#2 Codeforces Round #618 (Div. 2)

    A. Non-zero Description: Guy-Manuel and Thomas have an array \(a\) of \(n\) integers [\(a_1, a_2, \d ...

  5. Codeforces Round #618 (Div. 1)C(贪心)

    把所有数看作N块,后面的块比前面的块小的话就合并,这个过程可能会有很多次,因为后面合并后会把前面的块均摊地更小,可能会影响更前面地块,像是多米诺骨牌效应,从后向前推 #define HAVE_STRU ...

  6. Codeforces Round #618 (Div. 2)A. Non-zero

    Guy-Manuel and Thomas have an array aa of nn integers [a1,a2,…,an ]. In one step they can add 11 to ...

  7. Codeforces Round #618 (Div. 2)C. Anu Has a Function

    Anu has created her own function ff : f(x,y)=(x|y)−y where || denotes the bitwise OR operation. For ...

  8. Codeforces Round #618 (Div. 2) 小号上紫之路

    这一场涨了不少,题也比较偏思维,正好适合我 A. Non-zero 我们记录这些数字的总和sum,并且记录0的个数zero,显然答案应该是这些0的个数,注意如果sum+zero==0的话答案要额外加一 ...

  9. Codeforces Round #618 (Div. 2)-B. Assigning to Classes

    Reminder: the median of the array [a1,a2,-,a2k+1] of odd number of elements is defined as follows: l ...

随机推荐

  1. @HystrixCommand 不能被导包

    添加pom文件 <dependency>  <groupId>com.netflix.hystrix</groupId>  <artifactId>hy ...

  2. linux - python2.6.6 升级到python2.7.14

    一.升级 Python 2.7.14 版本 1. 准备安装包,系统是最小化安装 # 下载安装依赖的相关包[root@vip ~]# yum install vim gcc make wget -y [ ...

  3. CTF——代码审计之变量覆盖漏洞writeup【2】

    题目: 基础: 所需基础知识见变量覆盖漏洞[1]  分析: 现在的$a=’hi’,而下面的函数需满足$a=’jaivy’才可以输出flag,那么需要做的事就是想办法覆盖掉$a原来的值. 那么出现的提示 ...

  4. ECMAScript基本语法——③数据类型

    Java内有两种 基本数据类型:4类八种 引用数据类型:对象 JavaScript也有两种 原始数据类型 其实是基本数据类型 number:数字.整数.小数.NaN(特殊的数字,not a numbe ...

  5. [codeigniter4]Upgrading from 3.x to 4.x

    CodeIgniter 4 is a rewrite of the framework, and is not backwards compatible. It is more appropriate ...

  6. AcWing 1010. 拦截导弹

    //贪心加dp #include<iostream> using namespace std ; ; int n; int q[N]; int f[N]; int g[N];//存每个序列 ...

  7. cpu几核

    import psutil def GetCpuInfo(): cpu_count = psutil.cpu_count(logical=False) #1代表单核CPU,2代表双核CPU xc_co ...

  8. 记录 shell学习过程(6)while 以及 while的嵌套 以及 until

    while中的5种条件 1.数学比较 read -p "Num :" num1 ] do echo 'greater' sleep done 2.字符串比较 read -p &qu ...

  9. 查看杀死django进程

    #命令:#用于显示tcp,udp的端口和进程等相关情况netstat -tunlp"""ps:-t (tcp)仅显示tcp相关选项-u (udp)仅显示udp相关选项-n ...

  10. 边捆绑: Content Importance Based Edge Bundling for Graph Visualization

    Problem 当图所要表达的信息较多时, 图中可能会充满交叉的线[1-2], 甚至整个显示空间都被点.线所覆盖, 这时想通过观察来获取图中的重要信息将会变得非常困难, 这种现象称为图的视觉混乱. K ...