随笔分类 -  位运算

摘要:题目链接:http://codeforces.com/problemset/problem/769/D 题意:求给出的 n 个数中有多少对数字的二进制形式恰好有 k 位不同 思路:两个数a, b的二进制形式恰好 k 位不同即 a ^ b 中 1 的个数,那么可以枚举.注意 n 为 1e5 枚举 ai 阅读全文
posted @ 2017-06-10 16:16 geloutingyu 阅读(401) 评论(0) 推荐(0)
摘要:题目链接:http://codeforces.com/problemset/problem/768/C 题意:给出一个数组,经过k次操作后最大元素和最小元素分别是什么。。 操作:给当前数组排序,再将第奇数个元素异或 x; 思路:由于异或运算的性质,经过落干次操作后会形成稳定的数组; 代码: 1 #i 阅读全文
posted @ 2017-04-14 09:35 geloutingyu 阅读(495) 评论(0) 推荐(0)
摘要:题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1315 题意:中文题诶~ 思路:位或(|)运算是二进制位有一个为1就为1,否则为0.你们我们不难想到如果大于k的元素加入运算中其结果一定大于k, 与k异或结果大于 阅读全文
posted @ 2017-01-16 21:44 geloutingyu 阅读(196) 评论(0) 推荐(0)
摘要:题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=744 思路:a^b可以得到a~b间任意两个数异或运算的长度的最大值,设为n,答案为:pow(2, n)-1; (1):如果a,b长度相同的话,假设a^b得到的最高为1的位置为q(前面都是1异或值 阅读全文
posted @ 2016-10-10 21:49 geloutingyu 阅读(188) 评论(0) 推荐(0)
摘要:C. XOR and OR time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output C. XOR and OR time limit p 阅读全文
posted @ 2016-09-16 19:47 geloutingyu 阅读(323) 评论(0) 推荐(0)
摘要:B. New Year and Old Property time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The year 20 阅读全文
posted @ 2016-09-06 12:53 geloutingyu 阅读(223) 评论(0) 推荐(0)
摘要:Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That 阅读全文
posted @ 2016-09-04 16:36 geloutingyu 阅读(282) 评论(0) 推荐(0)