
算法杂谈
破晓aa
这个作者很懒,什么都没留下…
展开
-
Finite or not?
You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base bis a finite fraction.A fraction in notation wit...原创 2018-06-04 21:07:22 · 320 阅读 · 0 评论 -
D. Mike and Feet(单调栈)
D. Mike and Feet Mike is the president of country What-The-Fatherland. There are n bears living in this country ...原创 2018-07-21 17:42:58 · 470 阅读 · 0 评论 -
A - Longest k-Good Segment CodeForces - 616D (尺取法)
The array a with n integers is given. Let's call the sequence of one or more consecutive elements in a segment. Also let's call the segment k-good if it contains no more than k different values.Find...原创 2018-08-28 21:32:06 · 236 阅读 · 0 评论 -
求区间并集
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 1010;struct node{ int num; int pos;}sid[maxn];...原创 2018-09-29 09:15:51 · 1729 阅读 · 0 评论 -
Ice Cream Tower Gym - 101194D (二分答案、贪心检验)
题目:传送门Solution:二分答案和贪心检验就是这道题思路的核心,我来详细介绍一下其中的过程,直接算可以制造冰激凌的数量的话很困难,我感觉主要是有一个k的存在使得直接计算不好去想(我是不会的。。),但是检验的话就很好操作了,我们可以用二分的方法去一步一步缩小答案区间,最后就可以找到最大值了。那么该如何检验呢?为了使得数量最大,我们每次肯定挑最小的那个放在顶层,然后找它的下面一层。举...原创 2018-12-10 18:55:16 · 254 阅读 · 0 评论 -
双指针的奇妙用法
导语:有些问题问题的求解需要n2的复杂度,但是用双指针的话可以降低很多复杂度,举两个例子阐述一下双指针的用法。First:给定一个无序的数组a(长度为len)和一个数字k,让你求满足a[i] + a[j] &lt;= k(其中i != j)的(i, j)的数目。暴力跑的话两重for就可以解决了,并不复杂。但是这是n2的复杂度。再说说用双指针如何做(解释写代码里了),给出代码如下:i...原创 2019-01-09 10:15:17 · 2596 阅读 · 0 评论