随笔分类 -  Brute Force

1
摘要:这道题是给出一个n 求出分子分母 7 #include 8 #include 9 #include10 #include11 #include 12 #include13 #include14 #include15 #include 16 #include 17 using namespace std;18 19 int N;20 21 int print(int au,int ad,int bu,int bd)22 {23 if(ad+bd>N;39 40 cout<<"0/1"<<endl;41 print(0,1,1,1);42 cout 阅读全文
posted @ 2014-02-10 22:39 doubleshik 阅读(192) 评论(0) 推荐(0)
摘要:题目给出一个图, 问图中所有的“#”能否恰好独立的组成十字架(一个#只能在一个十字架中)一开始用dfs写的好混乱。。 后面发现从左上到右下,如果一个#满足正好在中间且四周可以消去,那就一定要消去,否则就NO。这样枚举一遍就好了。题目:B. Fox and Crosstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel has a board with n rows and n columns. So, the board cons 阅读全文
posted @ 2014-02-04 11:58 doubleshik 阅读(187) 评论(0) 推荐(0)
摘要:题意大致就是在给出的数列中不断取出 i,j 两个数,ai>aj , 然后把 ai-aj重新放入,直到不能做为止我用了个优先队列模拟。 因为可能同时有几个最大值。。所以不能单纯的比较最大值和后面一个最大值相等就停止题目:A. Fox and Number Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFox Ciel is playing a game with numbers now.Ciel has n positive i 阅读全文
posted @ 2014-02-04 11:54 doubleshik 阅读(321) 评论(0) 推荐(0)
摘要:就是找出最长的一个回文串 。。 一开始用了个朴素的dp。。结果应该是内存爆了开不了那么大数组。 然后就暴力枚举了回文的中间数字。过了。。感觉还是太低效题目: Calf Flac It is said that if you give an infinite number of cows an infinitenumber of heavy-duty laptops (with very large keys), that they willultimately produce all the world's great palindromes. Your job will beto d 阅读全文
posted @ 2014-01-31 20:50 doubleshik 阅读(307) 评论(0) 推荐(0)
摘要:枚举n/2个区间,判断 区间内的h和t是不是总数一半,是的话区间左边切一刀,右边切一刀( 一共最多切两刀)题目:Ice-sugar GourdTime Limit: 5000/2000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 740Accepted Submission(s): 264Problem DescriptionIce-sugar gourd, “bing tang hu lu”, is a popular snack in Beijing of China. It i 阅读全文
posted @ 2014-01-11 22:56 doubleshik 阅读(739) 评论(0) 推荐(0)
摘要:给出一些点,看最多有多少个点在同一个直线上。用每一个点作为起点,枚举与其他点的斜率,找出最大值。注意输出格式 和初始化最小ans为2;题目:Lining Up``How am I ever going to solve this problem?" said the pilot.Indeed, the pilot was not facing an easy task. She had to drop packages at specific points scattered in a dangerous area. Furthermore, the pilot could only 阅读全文
posted @ 2013-12-26 22:30 doubleshik 阅读(285) 评论(0) 推荐(0)
摘要:就是一个文件的很多副本碎成两半, 让你根据所有碎片求出原来的文件排序枚举一下就ok了题目:Question 2: File FragmentationThe ProblemYour friend, a biochemistry major, tripped while carrying a tray of computer files through the lab. All of the files fell to the ground and broke. Your friend picked up all the file fragments and called you to ask 阅读全文
posted @ 2013-12-24 21:54 doubleshik 阅读(332) 评论(0) 推荐(0)
摘要:题目就是求能否匹配所有交流生,让他们互相换。 。 一开始第一反应是训练指南上第一道勇士杀龙问题,利用排序比较。。虽然过了但是网上看到一个反例。。就是10 20,20 30,30 10,。。。 一个正确得方法是利用图的思想(有点类似跷跷板。具体看连接中博客吧)题目:Problem EForeign ExchangeInput: standard inputOutput: standard outputTime Limit: 1 secondYour non-profit organization (iCORE - international Confederation ofRevolver En 阅读全文
posted @ 2013-12-24 00:11 doubleshik 阅读(639) 评论(1) 推荐(0)
摘要:利用set 进行判断重复, 可以用dfs 因为只有11步。 我这里用了bfs题目:Problem DKnights in FENInput: standard inputOutput: standard outputTime Limit: 10 secondsThere are black and white knights on a 5 by 5 chessboard. There are twelve of each color, and there is one square that is empty. At any time, a knight can move into an em 阅读全文
posted @ 2013-12-23 15:06 doubleshik 阅读(259) 评论(0) 推荐(0)
摘要:题目大意就是倒水问题。 指定了一个最终状态d 。 如果达不到d ,则求出最接近d 的一个解熟悉了一下隐式图搜索题目:Problem DFillThere are three jugs with a volume of a, b and c liters. (a, b, and c are positive integers not greater than 200). The first and the second jug are initially empty, while the thirdis completely filled with water. It is allowed to 阅读全文
posted @ 2013-12-22 12:18 doubleshik 阅读(184) 评论(0) 推荐(0)
摘要:就是八皇后问题 。。题目:The Sultan's SuccessorsThe Sultan of Nubia has no children, so she has decided that the country will be split into up to k separate parts on her death and each part will be inherited by whoever performs best at some test. It is possible for any individual to inherit more than one or 阅读全文
posted @ 2013-12-20 21:08 doubleshik 阅读(284) 评论(0) 推荐(0)
摘要:就是连续邮资问题。。回朔法 sum 是求出每次最大连续的值backtrace 是枚举出每次的加入的值题目:StampsThe government of Nova Mareterrania requires that various legal documents have stamps attached to them so that the government can derive revenue from them. In terms of recent legislation, each class of document is limited in the number of st 阅读全文
posted @ 2013-12-20 20:32 doubleshik 阅读(175) 评论(0) 推荐(0)
摘要:题目大意是 只能利用左右交换完成一次排序,求一共有几种最小交换次数的方法按照题目的意思来dfs就行了。。自己写又写烦了。。受之前一道类似的题目影响,先求出最小方法数然后用子集构造去做。最后WA而且逆序多的话就卡了学习了别人的写法比较简单题目:Mapping the SwapsSorting an array can be done by swapping certain pairs of adjacent entries in the array. This is the fundamental technique used in the well-known bubble sort. If 阅读全文
posted @ 2013-12-19 23:54 doubleshik 阅读(213) 评论(0) 推荐(0)
摘要:有点小坑的一道题。。 一开始没多想就写了全排列看相邻两个球。。但是可能会有两个极大的圆。。。用坐标来确定每一个球的点。。枚举当前点和之前已经确定了圆相切后确定最右边的坐标,最后确定RECT最大值。题目: How Big Is It?Ian's going to California, and he has to pack his things, including his collection of circles. Given a set of circles, your program must find the smallest rectangular box in which 阅读全文
posted @ 2013-12-19 00:34 doubleshik 阅读(266) 评论(0) 推荐(0)
摘要:就是枚举+ 全排列一开始写复杂了,只要每次传进去写三次+-* 就行了题目:Problem I23 Out of 5Input: standard inputOutput: standard outputTime Limit: 1 secondMemory Limit: 32 MBYour task is to write a program that can decide whether you can find an arithmetic expression consisting of five given numbers (1 {1,2,3,4,5} is a bijective fun 阅读全文
posted @ 2013-12-18 16:19 doubleshik 阅读(235) 评论(0) 推荐(0)
摘要:一道暴力子集生成。。 一开始WA看了别人blog后据说是数据中两个int之间的空格可能不止一个。。然后用%d读取题目:The Broken PedometerThe ProblemA marathon runner uses a pedometer with which he is having problems. In the pedometer the symbols are represented by seven segments (or LEDs):But the pedometer does not work properly (possibly the sweat affecte 阅读全文
posted @ 2013-12-15 22:19 doubleshik 阅读(266) 评论(0) 推荐(0)
摘要:就是走迷宫 。。 在三维空间上。。题目:Dungeon MasterYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze 阅读全文
posted @ 2013-12-13 23:32 doubleshik 阅读(241) 评论(0) 推荐(0)
摘要:没什么动力刷刷水题。。 Palindromic SquaresRob Kolstad Palindromes are numbers that read the same forwards as backwards.The number 12321 is a typical palindrome. Given a number base B (2 12 #include 13 #include 14 using namespace std;15 16 bool judge(int b,int base)17 {18 19 int tmp[2000];20 int a=b*b;2... 阅读全文
posted @ 2013-12-10 20:16 doubleshik 阅读(225) 评论(0) 推荐(0)
摘要:一道暴力的题目。。枚举出来就好了。。一开始用自己写全排列都是WA 。。 可能是字典序什么的问题。。然后用了STL的全排列题目Getting in LineComputer networking requires that the computers in the network be linked.This problem considers a ``linear" network in which the computers are chained together so that each is connected to exactly two others except for 阅读全文
posted @ 2013-12-09 22:48 doubleshik 阅读(257) 评论(0) 推荐(0)
摘要:题目就是问如何用一条直线切蛋糕让直线两侧樱桃数量相等AX+BY=0 是直线 那么只要判断 AX1+BY1>0 与AX1+BY1using namespace std;int X[200];int Y[200];int main(){ int N; while(cin>>N &&N!=0) { for(int i=0;i>X[i]>>Y[i]; } for(int A=-500;A0)pos++; if(A*X[i]+B*Y[i]<0)neg++; if(A*X... 阅读全文
posted @ 2013-12-01 15:46 doubleshik 阅读(251) 评论(0) 推荐(0)

1