![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
暴力-技巧枚举
lab104_yifan
这个作者很懒,什么都没留下…
展开
-
UVA 10483 - The Sum Equals the Product (枚举技巧)
The Sum Equals the Product One day in a supermarket I witnessed the following scene. A young man put 3 items onto the conveyor belt and watched the cashier entering the numbers. He notic原创 2014-01-08 14:46:26 · 1286 阅读 · 0 评论 -
UVA 10574 - Counting Rectangles(枚举+计数)
10574 - Counting Rectangles题目链接题意:给定一些点,求能够成几个矩形思路:先把点按x排序,再按y排序,然后用O(n^2)的方法找出每条垂直x轴的边,保存这些边两点的y坐标y1, y2。之后把这些边按y1排序,再按y2排序,用O(n)的方法找出有几个连续的y1, y2都相等,那么这些边两两是能构成矩形的,为C2cnt种,然后累加起来就是答案代码:原创 2014-05-24 00:00:46 · 1399 阅读 · 0 评论 -
UVA 1560 - Extended Lights Out(高斯消元)
UVA 1560 - Extended Lights Out题目链接题意:给定一个矩阵,1代表开着灯,0代表关灯,没按一个开关,周围4个位置都会变化,问一个按的方法使得所有灯都变暗思路:两种做法:1、枚举递推这个比较简单,就枚举第一行,然后递推过去,每次如果上一行是亮灯,则下一行开关必须按下去2、高斯消元,这个做法比较屌一些,每个位置对应上下左右中5个位原创 2014-07-21 21:50:46 · 1994 阅读 · 0 评论 -
HDU 4876 ZCC loves cards(暴力剪枝)
HDU 4876 ZCC loves cards题目链接题意:给定一些卡片,每个卡片上有数字,现在选k个卡片,绕成一个环,每次可以再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个L,问能组成[L,R]所有数字的情况下,R的最大值是多少思路:暴力C(20, 6),然后对于每个序列去全排后模拟计算值, 不过之前要有个剪枝,全排前,先把k个数随机取数(即不用连续)原创 2014-07-24 22:51:07 · 1446 阅读 · 3 评论 -
UVA 1508 Equipment(技巧枚举)
UVA 1508 Equipment题目链接题意:给定n装备,每个装备对应5个分值,现在选出k个装备,5个位置的分值为每个装备最大的分值,问选出最大的分值和是多少思路:5个分值,那么对于每个装备,选到最大值位置其实有2^5总情况,先预处理出来,然后在这个基础上,每次去枚举集合即可,最多只要枚举5个集合(因为如果k > 5的话,其实答案就是选出5个分值对应最大的5个装备,其余原创 2014-07-28 01:00:57 · 815 阅读 · 0 评论 -
UVA 11898 - Killer Problem(鸽笼原理+计数排序+大力出奇迹)
UVA 11898 - Killer Problem题目链接题意:给定一个序列,每次询问一个[l,r],求出这个区间中选取两个不同位置的数字,他们的绝对值最小思路:想线段数,树状数组,RMQ之类搞,根本想不通怎么搞,于是看了下别人的讨论,发现居然是大力出奇迹,不过还是有用到点原理,就是由于数字最多1W,如果询问区间超过1W的话,必然会有两个一样的数字,绝对值就是0了,这样一原创 2014-08-02 22:48:22 · 1090 阅读 · 0 评论 -
HDU 4941 Magical Forest(离散化)
HDU 4941 Magical Forest题目链接题意:给定一些点,点有值,现在3种操作交换行,列,询问某个点值思路:这是签到题,坐标系很大,所以把坐标离散化储存,每次交换的时候只要把相应的行列坐标交换即可,查询就在交换过的上面查就可以了代码:#include #include #include #include using namespace原创 2014-08-12 23:35:57 · 972 阅读 · 0 评论 -
HDU 5024 Wang Xifeng's Little Plot(广州网络赛C题)
HDU 5024 Wang Xifeng's Little Plot题目链接思路:先利用记忆化搜索预处理出每个结点对应8个方向最远能走多远,然后枚举拐点记录最大值即可代码:#include #include #include using namespace std;const int d[8][2] = {{-1, 0}, {0, 1}, {1, 0},原创 2014-09-22 15:54:01 · 796 阅读 · 0 评论 -
HDU 5062 Beautiful Palindrome Number(暴力)
HDU 5062 Beautiful Palindrome Number题目链接才6种答案,直接暴力或者手算都可以代码:#include #include #include #include #include using namespace std;int t, n;int dfs(int u, int pre) { if (u == n) re原创 2014-10-11 22:42:56 · 708 阅读 · 0 评论 -
HDU 5063 Operation the Sequence(暴力)
HDU 5063 Operation the Sequence题目链接把操作存下来,由于只有50个操作,所以每次把操作逆回去运行一遍,就能求出在原来的数列中的位置,输出即可代码:#include #include #include using namespace std;typedef long long ll;const int N = 100005;原创 2014-10-11 22:44:51 · 891 阅读 · 0 评论 -
11589 - Save the President(暴力+技巧枚举)
链接:11589 - Save the President题意:有n个爆炸区域,每个区域有一个爆炸时间,现在要保护总统,要保证总统的生存空间为x, y, z;并且不被炸到,问有多少个不同时间空间的位置。思路:算上时间,算是一个四维坐标系,问题转化为四维坐标系上有一些点,你要找出前三维大小为(x,y,z)的所有位置。且这个大小内没有点。这题我直接暴力就过了。。而且时间很快,8层for原创 2014-03-28 22:23:12 · 1442 阅读 · 0 评论 -
UVA 12174 - Shuffle(技巧枚举+预处理)
You are listening to your music collection using the shuffle function to keep the music surprising. You assume that the shuffle algorithm of your music player makes a random permutation of the songs i原创 2014-02-11 02:20:36 · 2408 阅读 · 2 评论 -
UVA 11012 - Cosmic Cabbages(枚举技巧)
Problem ACosmic Cabbages Input: Standard InputOutput: Standard Output CABBAGE, n.A familiar kitchen-garden vegetable aboutas large and wise as a man's head.Ambrose原创 2014-01-09 18:47:39 · 1239 阅读 · 2 评论 -
UVA 10730 - Antiarithmetic?(技巧枚举)
Problem D: Antiarithmetic?A permutation of n is a bijective function of the initial n natural numbers: 0, 1, ... n-1. A permutation p is called antiarithmetic if there is no subsequence of it form原创 2014-01-25 22:31:21 · 1970 阅读 · 2 评论 -
UVA 1481 - Genome Evolution(枚举技巧)
Xi, a developmental biologist is working on developmental distances of chromosomes. A chromosome, in the Xi's simplistic view, is a permutation from n genes numbered 1 to n. Xi is working on an evol原创 2014-01-29 19:47:33 · 1491 阅读 · 0 评论 -
UVA 10755 - Garbage Heap(三维子矩阵最大和)
Garbage HeapTime limit: ? secondsMemory limit: 64 megabytesFarmer John has a heap of garbage formed in a rectangular parallelepiped.It consists of garbage pieces each of which has a value.原创 2014-01-20 14:35:26 · 2670 阅读 · 0 评论 -
1381 - Balancing the Scale (技巧枚举+位运算)
You are given a strange scale (see the figure below), and you are wondering how to balance this scale. After several attempts, you have discovered the way to balance it -- you need to put different nu原创 2014-02-06 03:38:11 · 1788 阅读 · 0 评论 -
1382 - Distant Galaxy(技巧枚举+离散化)
You are observing a distant galaxy using a telescope above the Astronomy Tower, and you think that a rectangle drawn in that galaxy whose edges are parallel to coordinate axes and contain maximum star原创 2014-02-07 01:00:54 · 1984 阅读 · 0 评论 -
UVA 1326 - Jurassic Remains(技巧枚举+位运算)
Paleontologists in Siberia have recently found a number of fragments of Jurassic period dinosaur skeleton. The paleontologists have decided to forward them to the paleontology museum. Unfortunately, t原创 2014-02-07 06:06:54 · 1670 阅读 · 0 评论 -
UVA 1432 - Fire-Control System(技巧枚举+线性扫描)
A new mighty weapon has just been developed, which is so powerful that it can attack a sector of indefinite size, as long as the center of the circle containing the sector is the location of the weapo原创 2014-02-10 08:17:17 · 1559 阅读 · 0 评论 -
1312 - Cricket Field(技巧枚举+离散化)
Once upon a time there was a greedy King who ordered his chief Architect to build a field for royal cricket inside his park. The King was so greedy, that he would not listen to his Architect's proposa原创 2014-02-10 08:18:02 · 1702 阅读 · 0 评论 -
POJ 3925 Minimal Ratio Tree(枚举+最小生成树)
POJ 3925 Minimal Ratio Tree题目链接题意:给定一些点权和一个边权矩阵,求一个最小的比例的树思路:先枚举用哪些点,然后求最小生成树即可代码:#include #include #include using namespace std;const int N = 20;int n, m, val[N], edge[N][N原创 2014-11-28 18:46:00 · 1332 阅读 · 0 评论