做一个类似与素数筛之类的预处理,然后就OK了。。...
分类:
其他好文 时间:
2014-08-11 17:59:42
阅读次数:
214
一、概念:贪心法(Greedy algorithm),是在每一步选择中都采用在当期状态下最好或最有的选择,从而希望导致结果是最好或者最优的算法。 比如在旅行推销员问题中,如果履行原每次都选择最近的城市,这就是一种贪心算法。 贪心算法在有最优子结构的问题中,尤为有效。最优子结构的意思是局部最优解...
分类:
其他好文 时间:
2014-08-04 13:24:47
阅读次数:
206
Problem Description
The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided t...
分类:
其他好文 时间:
2014-08-01 16:10:21
阅读次数:
184
Greedy, Greedy, Greedy.. It is all about maximum interval update.One trick is, we start looping over each element from the one nearest to end to farth...
分类:
其他好文 时间:
2014-08-01 13:32:21
阅读次数:
283
/** \brief hdu 1009--greedy
*
* \param date 2014/7/18
* \param state AC
* \return
*
*/
#include
#include
#include
#include
using namespace std;
const int MAXN=1001;
struct Data
{
int...
分类:
其他好文 时间:
2014-07-19 23:41:49
阅读次数:
237
Wall
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 29183
Accepted: 9768
Description
Once upon a time there was a greedy King who ordered his chief Archit...
分类:
其他好文 时间:
2014-07-19 02:45:15
阅读次数:
266
题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3794题目描述:N个城市,M条有向边。要从城市1开车到城市N,中途可以加油,也可以倒卖一次油,问最多能赚多少钱。油箱容量是C。N个城市中有P个城市(p1, p2…)可...
分类:
其他好文 时间:
2014-07-16 18:04:54
阅读次数:
483
Problem 1607 Greedy division...
分类:
其他好文 时间:
2014-07-06 00:45:19
阅读次数:
344
题目
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.
You should pack your words in a greedy approa...
分类:
其他好文 时间:
2014-06-29 23:44:02
阅读次数:
357
Codeforces印象
这两天抽时间去codeforces体验了一把。
首先,果然有众多大牛存在,很多名人一直参加每周一次的比赛,积分2000+,并参与出题。
另外,上面题目很多,估计至少一千题。比赛结束后,题目将转为练习题,可以持续尝试。每道题目都有标签,如greedy, math, matrices等等,可以点击相应的标签只做相关的题目。可惜我做了好几道之后才发现。
这次解决的题目...
分类:
其他好文 时间:
2014-06-25 07:27:52
阅读次数:
254