- 博客(35)
- 收藏
- 关注
原创 [HNOI2003]激光炸弹
一种新型的激光炸弹,可以摧毁一个边长为m的正方形内的所有目标。现在地图上有n个目标,用整数xi,yi表示目标在地图上的位置,每个目标都有一个价值vi.激光炸弹的投放是通过卫星定位的,但其有一个缺点,就是其爆破范围,即那个边长为m的边必须与x轴,y轴平行。若目标位于爆破正方形的边上,该目标不会被摧毁。现在你的任务是计算一颗炸弹最多能炸掉地图上总价值为多少的目标。...
2022-07-19 15:24:44
272
原创 Codeforces Round #771 (Div. 2) (A - C)
A题 (思维)题意:给出一个数列,然后可以任选一段区间,把这段区间倒转过来,求经过倒转后字典序最小的一个数列。样例:输入:41132 1 341 4 2 351 2 3 4 5输出:11 2 31 2 4 31 2 3 4 5解题思路:找到第一次出现a[i]!=i的位置,标记这个位置以及i的值,然后寻找i的值所在的位置,将这段区间反转即可。AC代码:#include <bits/stdc++.h>using namespace std;const i
2022-02-22 22:05:46
147
原创 Borg Maze (最小生成树+bfs)
Borg Maze题目描述:The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. Each Borg individual is linked to the col
2021-08-17 10:13:14
407
原创 ACM Contest and Blackout (次小生成树kruskal)
ACM Contest and Blackout题目描述:In order to prepare the “The First National ACM School Contest” (in 20??) the major of the citydecided to provide all the schools with a reliable source of power. (The major is really afraid ofblackoutsJ). So, in order to d
2021-08-13 16:22:00
128
原创 Arctic Network (最小生成树 Kruskal +贪心)
Arctic Network题目描述:The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the network: every outpost will have a radio transceive
2021-08-13 16:05:05
245
原创 Building a Space Station (最小生成树 Kruskal)
Building a Space Station题目描述:You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.The space station is made up with
2021-08-13 15:38:08
204
原创 Highways (最小生成树 Kruskal)
Highways题目描述:The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a number of highways connecting some of the mos
2021-08-13 15:13:48
216
原创 Jungle Roads (最小生成树)
Jungle Roads题目描述:The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expens
2021-08-13 14:41:21
123
原创 最小生成树 (Prime算法+Kruskal算法)
Prime算法:[关于算法的过程演示:](https://blog.csdn.net/lqcsp/article/details/14118871)
2021-08-12 14:38:22
563
原创 最长上升子序列(LIS)
最长上升子序列题目描述:给定一个长度为 N 的数列,求数值严格单调递增的子序列的长度最长是多少。输入格式第一行包含整数 N。第二行包含 N 个整数,表示完整序列。输出格式输出一个整数,表示最大长度。数据范围1≤N≤1000,−109≤数列中的数≤109输入样例:73 1 2 1 8 5 6输出样例:4题解:最长上升子序列,由于数据范围较小,这里可以用时间复杂度为o(n^2)的方法,也就是用动态规划,具体做法如下:1、设多维数组:这里只需要一维数组即可,dp[ i ]代表以第
2021-07-24 09:43:13
262
原创 Stock Exchange(LIS优化)
Stock Exchange题目描述:The world financial crisis is quite a subject. Some people are more relaxed while others are quite anxious. John is one of them. He is very concerned about the evolution of the stock exchange. He follows stock prices every day looking
2021-07-24 09:11:52
237
原创 饭卡(动态规划+贪心)
饭卡题目描述:电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正整数n,表示菜的数量。n<=1000。第二行包括n个正整数,表示每种菜的价格。价格不超过50。第三行
2021-07-24 08:44:19
296
原创 数字三角形(dp)
数字三角形题目描述:观察下面的数字金字塔。写一个程序来查找从最高点到底部任意处结束的路径,使路径经过数字的和最大。每一步可以走到左下方的点也可以到达右下方的点。73 88 1 02 7 4 44 5 2 6 5在上面的样例中,从 7 \to 3 \to 8 \to 7 \to 57→3→8→7→5 的路径产生了最大输入格式第一个行一个正整数 rr ,表示行的数目。后面每行为这个数字金字塔特定行包含的整数。输出格式单独的一行,包含那个可能得到
2021-07-22 15:52:53
352
原创 棋盘问题(DFS)
棋盘问题(DFS)在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n当为-1 -1时表示输入结束。随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区
2021-06-03 20:24:22
606
原创 Red and Black(DFS)
Red and BlackThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move only on b
2021-06-03 19:46:22
119
原创 Oil Deposits(DFS)
Oil DepositsThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits.GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that dividesthe land into numerous square plots. It then
2021-06-03 19:00:56
113
原创 [CQOI2010]扑克牌
标题[CQOI2010]扑克牌(二分答案)链接:https://ac.nowcoder.com/acm/problem/19916来源:牛客网题目描述你有n种牌,第i种牌的数目为ci。另外有一种特殊的牌:joker,它的数目是m。你可以用每种牌各一张来组成一套牌,也可以用一张joker和除了某一种牌以外的其他牌各一张组成1套牌。比如,当n=3时,一共有4种合法的套牌:{1,2,3}, {J,2,3}, {1,J,3}, {1,2,J}。 给出n, m和ci,你的任务是组成尽量多的套牌。每张牌最多只能
2021-05-17 20:53:21
658
原创 小咪买东西(二分+贪心+01分数规划)
小咪买东西(二分+贪心+01分数规划)小咪是一个土豪手办狂魔,这次他去了一家店,发现了好多好多(n个)手办,但他是一个很怪的人,每次只想买k个手办,而且他要让他花的每一分钱都物超所值,即:买下来的东西的总价值/总花费=max。请你来看看,他会买哪些东西吧。输入描述:多组数据。第一行一个整数T,为数据组数。接下来有T组数据。对于每组数据,第一行两个正整数n,k,如题。接下来n行,每行有两个正整数ci,vi。分别为手办的花费和它对于小咪的价值。输出描述:对于每组数据,输出一个数,即能得到的总价
2021-05-12 15:51:50
245
原创 Graveyard Design(尺取法)
Graveyard Design(尺取法)题目描述: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 of which must be a square of graves. All sections must have different number
2021-05-05 20:25:29
330
原创 pairs(尺取)
pairs(尺取)题目描述:John has n points on the X axis, and their coordinates are (x[i],0),(i=0,1,2,…,n−1). He wants to know how many pairs<a,b> that |x[b]−x[a]|≤k.(a<b)InputThe first line contains a single integer T (about 5), indicating the number of
2021-05-05 15:41:11
178
原创 Jessica‘s Reading Problem(尺取法)
Jessica’s Reading Problem(尺取法)题目描述:Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas included in a very thic
2021-05-05 08:41:05
227
2
原创 P1303 A*B Problem(高精度乘法)
P1303 A*B Problem(高精度乘法)description:求两数的积。输入格式两行,两个整数。输出格式一行一个整数表示乘积。输入12输出2说明/提示每个数字不超过 10^2000题解:这道题用的是高精度乘法,我的思路是先用字符串的方式输入两个高精度数,分别倒序存入两个整形数组中。在双重循环中用第二个数组中的每一位乘第一个数组中的每一位,结果保留在一个二维数组中,然后把每次存的结果相加,倒序输出可得到答案。#include <stdio.h>#in
2021-04-19 20:43:03
283
原创 Big Number(大数取模)
Big Number(大数取模)description:As we know, Big Number is always troublesome. But it’s really important in our ACM. And today, your task is to write a program to calculate A mod B.To make the problem easier, I promise that B will be smaller than 100000.Is
2021-04-18 09:48:20
395
原创 How Many Fibs?(高精度+打表+字符比较)
How Many Fibs?(高精度+打表+字符比较)description:Recall the definition of the Fibonacci numbers:f1 := 1f2 := 2fn := fn-1 + fn-2 (n >= 3)Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b].InputThe input contains several
2021-04-18 09:15:45
173
原创 Hat‘s Fibonacci(高精度+打表)
Hat’s Fibonacci(高精度+打表)description:A Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1.F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4)Your ta
2021-04-18 08:57:40
108
原创 大菲波数(高精度+打表)
大菲波数(高精度+打表)description:Fibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3。计算第n项Fibonacci数值。Input输入第一行为一个整数N,接下来N行为整数Pi(1<=Pi<=1000)。Output输出为N行,每行为对应的f(Pi)。Sample Input512345Sample Output11235题解:数据量大,unsigned long long 也存
2021-04-17 20:46:23
2922
原创 大明A+B(高精度小数)
大明A+B(高精度小数)description:话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。Input本题目包含多组测试数据,请处理到文件结束。每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。Output请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Outp
2021-04-17 19:34:36
263
原创 Strange fuction(二分答案)
Strange fuction(二分答案)Description:Now, here is a fuction:F(x) = 6 * x7+8*x6+7x3+5*x2-yx (0 <= x <=100)Can you find the minimum value when x is between 0 and 100.InputThe first line of the input contains an integer T(1<=T<=100) which means
2021-03-28 20:55:33
186
原创 Can you find it?(二分查找)
Can you find it?(二分查找)Description:Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formula Ai+Bj+Ck = X.InputThere are many cases. Every
2021-03-28 20:39:18
341
原创 Pie(二分答案)
Pie(二分答案)Description:My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This sh
2021-03-28 20:20:42
301
原创 A^B mod C(快速幂+快速乘)
A^B mod C(快速幂+快速乘)Description:Given a, b, c find the value of ab mod c (1 ≤ a, b, c < 263).InputContains multiple test cases. Each test is given in one line and contains three integers a, b and c.OutputFor each test case print on a separate line t
2021-03-28 19:48:45
355
原创 Rightmost Digit(快速幂)
Rightmost Digit(快速幂)Description:Given a positive integer N, you should output the most right digit of N^N.InputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases foll
2021-03-28 19:42:00
235
原创 Moving Tables
Moving TablesDescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made
2021-03-22 20:40:44
167
原创 Best Cow Line(贪心)
Best Cow Line(贪心)DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual”Farmer of the Year” competition. In this contest every farmer arranges his cows in a line and herds them past the judges.The contest organizers adopted a new regist
2021-03-22 20:04:47
148
原创 Saruman‘s Army(贪心)
Saruman’s Army(贪心)DescriptionSaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effect
2021-03-22 19:25:00
186
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人