CF-1013 A. Piles With Stones 比较两个序列的和,因为只能拿走或者不拿,所以总数不能变大. B. And 答案只有 -1,0,1,2几种可能,所以对于每一种答案都暴力扫一次是可以的 或者对于每个 \(a_i\) ,将\(a_i\) 标记加一,如果\(a_i \neq a_i\& x\) ,将\(a_i\&x\) 用另一个数组标记加一.然后整体扫一次就可以了 #include <bits/stdc++.h> using namespace std; in…
A. Thanos Sort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to rem…
A题意思是,给出两个数列,求一个区间,使第一个数列的区间或和第二个数列的区间或的和最大,输出最大和 很显然,或运算会使得答案越运算越大.所以,直接全部或起来,相加就是答案. = =打cf的时候自动脑补成异或,浪费了好多时间,超出int情况一开始没有考虑,于是加一次重交. #include <cstdio> const int N=1005; long long a[N],b[N]; int n; int main(){ scanf("%d",&n); for(int…
如果要搞懂Java中的位运算符,首先要搞懂二进制的运算,之前一篇有介绍详细请看 二进制运算-十进制与二进制的转换 Java中的位运算符有:&(按位与).|(按位或).^(按位异或).>>(右移).<<(左移).~(取反).>>>(无符号右移) 下面来逐一介绍: &(按位与) int i = 5&2; int j = 7&3; System.out.println("i="+i);//i=0 System.out.…