![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
题解
文章平均质量分 92
R_emembers
这个作者很懒,什么都没留下…
展开
-
brz的杯子 - 牛客练习赛72
brz的杯子 题目 题解 y|x 是能够整除的意思 推断序列 位置:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 数字:1,2,2,3,2,3,2,4,3, 3, 2, 4, 2, 3, 3, 5, 2 发现每到下标为2的幂的位置,所需要的最大数都会加1,这个数字等价于下标二进制的位数。 所以对于n个瓶子,只有当m>=n的二进制位数时才会存在可行的方案。 代码 #include <iostream> #include <cstdio> #原创 2020-11-08 12:00:08 · 117 阅读 · 0 评论 -
Codeforces Round #673 (Div. 2)
Codeforces Round #673 (Div. 2) 传送门 A. Copy-paste 题解 贪心,最小的一个个往后加。 代码 #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #define ll long long using namespace std; int a[1005]; int m原创 2020-09-28 22:30:10 · 92 阅读 · 0 评论 -
2020中国大学生程序设计竞赛(CCPC) - Lunch (HUD 6892)
1005 Lunch Lunch 题意: 给你n块巧克力,长度已知。现有如下操作 1.在每个回合中,玩家需要选择一块巧克力。如果选择了等于1长度的巧克力,则该玩家输掉游戏。 2.假设所选巧克力的长度是l,那么玩家需要选择一个满足k至少为2且k是l的因子的正整数k。 3.然后玩家需要将选中的巧克力切成k个长度为l/k的巧克力。 每个人取最优解,问两人比赛,谁会赢。 题解: 这一是一个博弈论题目,想到每个巧克力作为一个局面,后继操作使局面可以“分裂”,”分裂“后各个局面取xor和得sg,所有局面sg求mex即可原创 2020-09-22 21:12:27 · 966 阅读 · 0 评论 -
牛客每日一题 7月3日 毒瘤xor (前缀和+贪心)
毒瘤xor 题目 毒瘤xor 异或 异或(^) 运算规则:0 ^ 0 = 0 ,0 ^ 1 = 1, 1 ^ 0 = 1, 1 ^ 1 = 1. 题解 本题如果原来的数这一位是1,它异或一个0;如果原来是0,异或1。我们用一个前缀数组记录每一位的1的数量,如果1更多,我们就让他异或一个0, 如果0更多, 就异或一个1。前缀和的处理是需要(n*30)。 代码 #include <iostream> #include <cstdio> #define ll long long us转载 2020-09-16 21:41:14 · 145 阅读 · 0 评论 -
牛客每日一题 7月15日-生日快乐(DFS)
生日快乐 题目 生日快乐 题解 大概意思给你一个nm的矩形,切成n等分,并且长宽比的最大值最小。 dfs的方向就是我们枚举每一刀的位置即可,对于当前矩形假如要把它切成k块,下一刀的取法只有2(k-1)种方案,取最小的一种即可。 代码 #include <iostream> #include <cstdio> #include <cmath> using namespace std; double dfs(double x, double y, int n) {转载 2020-09-16 21:25:16 · 132 阅读 · 0 评论 -
牛客每日一题 3月20日 滑动窗口(优先队列)
滑动窗口(优先队列) 题目链接:滑动窗口 题解: 我们用一个双端队列来维护(普通的队列只能从队尾加入元素从队首删除元素,双端队列的队尾也可也删除元素),区间每次右移一个单位,首先看看队首的元素是否超出了范围,如果超出了,就把它删掉;然后将新进入区间的这个元素往双端队列里放,但放进来之前需要判断队尾(也就是还有可能成为最大值的最后一个元素)是不是小于最后一个元素,如果是,就把这个队尾删掉,一直到前一个元素大于等于它为止。由于我们队列里面的元素实际上是单调不增的,每次的最大实际上就在队首。而由于每个数进队和出转载 2020-08-07 14:05:21 · 152 阅读 · 0 评论 -
AtCoder Beginner Contest 174
AtCoder Beginner Contest 174 比赛地址 A - Air Conditioner 题解 签到题 代码 #include <iostream> #include <cstdio> using namespace std; int main() { int x; scanf("%d", &x); if(x >= 30) printf("Yes\n"); else printf("No原创 2020-08-07 13:55:59 · 151 阅读 · 0 评论 -
牛客每日一题 3.25 tokitsukaze and Soldier (贪心+优先队列)
题目 题解 枚举选择多少个物品,显然所有不低于此限制的物品均能选择,则使用一个优先队列储存当前选择的物品,先加入符合限制的,然后在删除容量的最小的部分即可。 代码 #include <iostream> #include <queue> #include <algorithm> #define LL long long using namespace std; const int MAXN = 100020; priority_queue<LL, vector&l原创 2020-07-29 14:54:24 · 153 阅读 · 0 评论 -
Codeforces Round #658 (Div. 2)
Codeforces Round #658 (Div. 2) A. Common Subsequence 题意: 找两个字符串最短的公共子序列 题解: 用桶排序记录有是否出现过,出现过就输出 代码: #include <iostream> #include <cstring> using namespace std; int a[1005]; int b[1005]; int num[1005]; int main() { int t, n, m; cin >>原创 2020-07-27 10:40:09 · 97 阅读 · 0 评论 -
Codeforces Round #656 (Div. 3)
Codeforces Round #656 (Div. 3) A. Three Pairwise Maximums 题意:对于每组测试样例给出三个数x y z,你需要寻找三个数a, b, c使得x = max(a,b) y = max(a,c) z = max(b,c) 如果能找到则输出YES按任意顺序打印abc 题解:因为z是a、b和c三个整数中的最大值,并且它以两对出现(因此它在x、y和z中最多出现两次)。否则,答案就存在了,它可以是x,x和z, 代码: #include <iostream>原创 2020-07-20 20:17:33 · 106 阅读 · 0 评论 -
Codeforces Round #646 (Div. 2)
Codeforces Round #646 (Div. 2) 题目链接:Codeforces Round #646 (Div. 2) A. Odd Selection 代码 #include<iostream> using namespace std; int main() { int t; cin >> t; while (t--) { int n, x, a, sum = 0, Odd = 0, Oeve = 0; cin原创 2020-06-02 20:47:22 · 165 阅读 · 0 评论 -
Codeforces Round #644 (Div. 3)
Codeforces Round #644 (Div. 3) 比赛链接 :Codeforces Round #644 (Div. 3) A. Minimal Square 题意:找出 a*b 正方形最小的面积 题解:比较边的(a2,b)或(a,b2)的长短 代码: #include <iostream> using namespace std; int main() { int t, n, m; cin >> t; while(t--) { cin >> n原创 2020-05-26 21:00:15 · 145 阅读 · 0 评论 -
E. Special Elements(cf#640)
E. Special Elements 题意 给定元素个数<=8000且元素大小<=8000的数组,问其中可表示为连续子序列的和的元素有多少个 题解 求出所有子序列和然后再匹配元素,和大于8000就不需要了 #include <iostream> #include<cstring> using namespace std; int visit[8100]; //用桶数组来装所有的子序列和 int a[8100]; int b[8100]; int main() {原创 2020-05-23 21:11:32 · 189 阅读 · 0 评论