随笔分类 -  算法基础—位运算

摘要:#include <bits/stdc++.h> #define gcd(a, b) __gcd(a, b) #define INF 0x3f3f3f3f3f #define eps 1e-6 #define PI acos(-1.0) #define pb push_back #define fs 阅读全文
posted @ 2022-03-05 22:47 脂环 阅读(51) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11259/D 来源:牛客网 题目描述 There are two sequences of length n−1n−1, b=(b2,b3,…,bn)b=(b2,b3,…,bn), c=(c2,c3,…,cn)c=(c2 阅读全文
posted @ 2021-08-09 21:03 脂环 阅读(54) 评论(0) 推荐(1) 编辑
摘要:A You are given 𝑛n integers 𝑎1,𝑎2,…,𝑎𝑛a1,a2,…,an. Find the maximum value of 𝑚𝑎𝑥(𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟)⋅𝑚𝑖𝑛(𝑎𝑙,𝑎𝑙+1,…,𝑎𝑟)max(a 阅读全文
posted @ 2021-07-30 12:46 脂环 阅读(474) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int n, k; void process() { int r; cin >> r; if(r == 1) return; for(int i = 1; i < n; i++) { cout << (i ^ 阅读全文
posted @ 2021-07-13 15:58 脂环 阅读(40) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> using namespace std; int n; int x[200005], y[200005], xr[200005]; int main() { int t; cin >> t; while(t--) { cin >> n; for(in 阅读全文
posted @ 2021-07-11 15:02 脂环 阅读(67) 评论(0) 推荐(0) 编辑
摘要:Yen-Jen loves cat very much. Now, there are 10^{18}1018 cats standing in a line, the i^ith cat's cost value c_ic**i is equal to ii, the i^ith cat's in 阅读全文
posted @ 2021-05-11 19:46 脂环 阅读(70) 评论(0) 推荐(0) 编辑
摘要:给你一个整数数组 perm ,它是前 n 个正整数的排列,且 n 是个 奇数 。 它被加密成另一个长度为 n - 1 的整数数组 encoded ,满足 encoded[i] = perm[i] XOR perm[i + 1] 。比方说,如果 perm = [1,3,2] ,那么 encoded = 阅读全文
posted @ 2021-05-11 19:28 脂环 阅读(110) 评论(0) 推荐(0) 编辑
摘要:给你一个整数数组 nums ,除某个元素仅出现 一次 外,其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 示例 1: 输入:nums = [2,2,3,2] 输出:3 示例 2: 输入:nums = [0,1,0,1,0,1,99] 输出:99 提示: 1 ⇐ nums.len 阅读全文
posted @ 2021-04-30 19:07 脂环 阅读(82) 评论(0) 推荐(0) 编辑
摘要:题目描述 现有n个砝码,重量分别为 a_ia**i,在去掉 mm 个砝码后,问最多能称量出多少不同的重量(不包括 00)。 请注意,砝码只能放在其中一边。 输入格式 第 11 行为有两个整数 nn 和 mm,用空格分隔。 第 22 行有 nn 个正整数 a_1, a_2, a_3,\ldots , 阅读全文
posted @ 2020-12-17 20:26 脂环 阅读(220) 评论(0) 推荐(0) 编辑
摘要:Pang believes that one cannot make an omelet without breaking eggs. For a subset 𝐴A of {1,2,…,𝑛}{1,2,…,n}, we calculate the score of 𝐴A as follows: 阅读全文
posted @ 2020-12-15 11:56 脂环 阅读(132) 评论(0) 推荐(0) 编辑
摘要:The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped 阅读全文
posted @ 2020-06-07 21:37 脂环 阅读(300) 评论(0) 推荐(0) 编辑
摘要:Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usual 阅读全文
posted @ 2020-06-07 21:33 脂环 阅读(305) 评论(0) 推荐(0) 编辑
摘要:In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p: ⊕ is the xor operator. We say a path the 阅读全文
posted @ 2020-06-03 14:37 脂环 阅读(228) 评论(0) 推荐(0) 编辑
摘要:题目描述 给出一个小于2322^{32}232的正整数。这个数可以用一个323232位的二进制数表示(不足323232位用000补足)。我们称这个二进制数的前161616位为“高位”,后161616位为“低位”。将它的高低位交换,我们可以得到一个新的数。试问这个新的数是多少(用十进制表示)。 例如, 阅读全文
posted @ 2020-03-15 16:08 脂环 阅读(618) 评论(0) 推荐(1) 编辑
摘要:题目描述 经过一段时间的紧张筹备,电脑小组的“RP餐厅”终于开业了,这天,经理LXC接到了一个定餐大单,可把大家乐坏了!员工们齐心协力按要求准备好了套餐正准备派送时,突然碰到一个棘手的问题,筷子!CX小朋友找出了餐厅中所有的筷子,但遗憾的是这些筷子长短不一,而我们都知道筷子需要长度一样的才能组成一双 阅读全文
posted @ 2020-03-15 15:47 脂环 阅读(128) 评论(0) 推荐(0) 编辑
摘要:Anu has created her own function ff : f(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9. It can be proved 阅读全文
posted @ 2020-02-10 13:20 脂环 阅读(158) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
主题色彩