Problem Description Memphis loves xor very musch.Now he gets an array A.The length of A is n.Now he wants to know the sum of all (lowbit(Ai xor Aj) (i,j∈[1,n]) We define that lowbit(x)=2^k,k is the smallest integer satisfied ((x and 2^k)>0)Specially,…
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Tonio has a keyboard with only two letters, "V" and "K". One day, he has typed out a string s with only t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2095 解题思路:因为只有我们要求的那个数出现的次数为奇数,所以可以用位运算来做,两次异或同一个数最后结果不变,那么就可以知道异或运算相当于过滤掉了出现次数为偶数的数,最后只留下了唯一的那一个出现次数为奇数的数. 反思:位运算好陌生,好好学. #include<stdio.h> int main() { int n; long int a; while(scanf("%d",&a…
题目链接:https://ac.nowcoder.com/acm/contest/2720/D 题意:对于 ax = by = c ,给出 x, y 求符合条件的 a, b, c 且 c 为最小的解,不满足条件输出 -1. idea:容易看出 c 为x, y 的最小公倍数.设最小公倍数为 s ,所以 a = s / x,b = s / y.因为 s = x * y / __gcd(x,y) ,所以 a = y / __gcd(),b = x / __gcd(),所以 x 和 y 一定互质.若__…