算法竞赛题解
文章平均质量分 61
仰望—星空
我不懒,还没有简历
展开
-
Radar Installation
题目描述 题目来源解题思路 想法1.0 。最初我的想法是:存储记录坐标后,按x的大小顺序排序坐标。然后从小坐标(横坐标)到大坐标遍历,用一个MaxX记录安装的雷达的最大横坐标,对每一个x。如果它到(MaxX,0)的距离小于等于d则直接继续找下一个如果它到(MaxX,0)的距离大于d,则设x和y为坐标,在(x+sqrt(dd-yy),0)处安装雷达。这种想法是按横坐标从小到大即坐标轴从左往右对于每一个岛屿先检测与横坐标最大的雷达的距离是否大于d,如果大于则在x轴上距离岛屿d处的右侧的点上建立雷达,如此直原创 2021-07-12 14:14:21 · 123 阅读 · 0 评论 -
P1216 数字三角形 Number Triangles(滚动数组)
题目描述题目地址解题思路滚动数组导引链接 使用滚动数组进行解题! 我们要求的最大路径和,路径是从第一层到最后一层,每一次可以往下也可以往坐下(斜着走),所以我们如果常规求解是递归求解,求解以i,j为起点使路径和的最大值,这是自下而上的求解方法(因为求解出了所有的解)。这种解法的空间复杂度为O(n^2),使用空间较高,如在n=1000000时我们就无法使用静态数组去存储,那我们能不能优化它呢? 答案当然是肯定的,我们可以将空间节约到O(n)!即只使用最后一层的节点个数那么大的数组存储答案。这样可行原创 2021-07-01 15:04:22 · 207 阅读 · 0 评论 -
P1095 [NOIP2007 普及组] 守望者的逃离
题目描述 题目来源解题思路 模拟+贪心AC代码#include<iostream>#include<cstring>#include<math.h>using namespace std;int HuiFuTime(int M){ double time = (10.0 - M) / 4.0; if (time != (int)time)time = (int)time + 1;//行为都必须占用一整秒 return (int)time;}原创 2021-06-29 14:10:55 · 187 阅读 · 0 评论 -
P1091 [NOIP2004 提高组] 合唱队形
题目描述 NN位同学站成一排,音乐老师要请其中的(N-KN−K)位同学出列,使得剩下的KK位同学排成合唱队形。 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2,…,K1,2,…,K,他们的身高分别为T_1,T_2,…,T_KT 1,T 2 ,…,T K , 则他们的身高满足T_1<…<T_i>T_{i+1}>…>T_K(1 \le i \le K)T 1 <…T i+1 >…>T K (1≤i≤K)。 你的任务是,已知所有NN位同原创 2021-06-28 22:48:41 · 593 阅读 · 1 评论 -
P1020 [NOIP1999 普及组] 导弹拦截
题目描述题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。 输入导弹依次飞来的高度(雷达给出的高度数据是\le 50000≤50000的正整数),计算这套系统最多能拦截多少导弹,如果要拦截所有导弹最少要配备多少套这种导弹拦截系统。 题目来源解题思路 狄尔沃斯定理(Dilw原创 2021-06-28 16:27:02 · 2027 阅读 · 0 评论 -
Buying Shovels(数学)
题目 Polycarp wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the i-th type consists of exactly i shovels (1≤i≤k). The store has an infinite number of packages of each type. Polycarp w原创 2021-06-28 14:16:35 · 154 阅读 · 0 评论 -
L - Swimmer
题目题目来源B - Problem SelectHOJ is an online judge system for students in HIT to practice. As the administrator, you would always setup contests by selecting problems from the problem set. Problem IDs are integers that can be phased by url. For example, the原创 2021-05-30 22:01:54 · 265 阅读 · 14 评论 -
P1678 烦恼的高考志愿
二分查找题目来源题解(AC)题目来源烦恼的高考????????题解(AC)#include <cstdio>#include<iostream>#include <cstring>#include <cmath>#include <algorithm>#include<vector>using namespace std;int a[100000],b[100000];int m, n;int erfen(i原创 2021-05-30 20:55:31 · 310 阅读 · 3 评论 -
P2249 查找
有重复二分查找题目来源题解(AC+注释)题目来源查找题解(AC+注释)#include<iostream>#include<cstring> using namespace std;const int N=1000000;int a[N];int n;int erfen(int x){ int left = 0, right = n - 1,mid; while (left < right)//保证从left到right为查找元素组成的子序原创 2021-05-30 13:25:30 · 169 阅读 · 2 评论 -
P1601 A+B Problem
A+B题目来源标解(AC+注释)题目来源A+B标解(AC+注释)#include<iostream>#include<cstring> using namespace std;void FanZhuan(char a[]){ int l = strlen(a) - 1; int n = l / 2; for (int i = 0; i <= n; i++) { char tmp = a[i]; a[原创 2021-05-30 12:29:10 · 64 阅读 · 1 评论 -
2019CCPC-江西省赛-Worker
题目Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m workers. Any worker in the i-th warehouse can handle ai orders per day. The customer wonders whether there exists one worker as原创 2021-05-23 10:04:29 · 167 阅读 · 2 评论 -
2019CCPC省赛-String
题目Avin has a string. He would like to uniform-randomly select four characters (selecting the same character is allowed) from it. You are asked to calculate the probability of the four characters being ”avin” in order.InputThe first line contains n (1 ≤原创 2021-05-23 09:37:36 · 287 阅读 · 0 评论