随笔分类 - 技巧—二分
摘要:准备C复试的一部分,有些题比较有趣,限制了时间或空间复杂度后,确实挺难想到的。比如给一个数组,里面有且仅有一个重复的数字,然后限定空间复杂度O(1),求解
阅读全文
摘要:题意 有一个长为的序列,输出:出现最多次数的长度为的子序列。 题解 二分枚举子序列的出现次数,然后检查是否有个数出现了次。 代码 ~~~c++ const int N = 200005;
阅读全文
摘要:ps:就一个普通的二分。。。永远都是debug的时间比写代码的时间还长
阅读全文
摘要:Given an array having N elements, each element is either -1 or 1. You have M queries, each query has two numbers L and R, you have to answer the lengt
阅读全文
摘要:Problem Description 有一台机器,并且给你这台机器的工作表,工作表上有n个任务,机器在ti时间执行第i个任务,1秒即可完成1个任务。有m个询问,每个询问有一个数字q,表示如果在q时间有一个工作表之外的任务请求,请计算何时这个任务才能被执行。机器总是按照工作表执行,当机器空闲时立即执
阅读全文
摘要:Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two posi
阅读全文
摘要:A game field is a strip of 1 × n square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty. Packman can move to
阅读全文
摘要:Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tightrope wa
阅读全文
摘要:In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Given your test
阅读全文
摘要:Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The exciteme
阅读全文
摘要:It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has dec
阅读全文
摘要:Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤ i < j ≤ N). We can get C(N,2) differences
阅读全文
摘要:Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the
阅读全文
摘要:King George has recently decided that he would like to have a new design for the royal graveyard. The graveyard must consist of several sections, each
阅读全文
摘要:As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some po
阅读全文
摘要:One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already ex
阅读全文
摘要:This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a s
阅读全文
![](https://images.cnblogs.com/cnblogs_com/zgglj-com/1682556/o_200327152908zg.jpg)