先说下题目的意思: 在一个二维坐标系中有N个点,某人要来个走遍所有点的旅行,但是他的车每次加油后只能走M个单位距离;所以要在这个N点中选一些建立加油站;问题来了:i^th 点 建加油站的花费是 2^(i-1); 求最小话费 用二进制表示;(其中1号必须建立加油站) 思路:有 1000...
分类:
其他好文 时间:
2014-10-02 14:11:03
阅读次数:
159
题目地址:HDU 2448
求n次最短路,将n艘船到各港口的最短路求出来,然后用最短路当费用,跑一次费用流。
代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
cons...
分类:
其他好文 时间:
2014-09-30 12:11:59
阅读次数:
223
//假设sum为总的耗油量,max为起始点a到终点b的耗油量,如果,当到达b的时候,
//max < 0,那么,出发点肯定不能从a开始,这个时候将max = 0,然后,pos = i+1,选择pos为起始点,然后继续遍历。
//如果,最后的sum = 0,则返回pos.
class Solution {
public:
int canCompleteCircuit(std::vector ...
分类:
其他好文 时间:
2014-09-27 15:36:29
阅读次数:
198
Channel AllocationTime Limit:1000MSMemory Limit:10000KTotal Submissions:12334Accepted:6307DescriptionWhen a radio station is broadcasting over a very ...
分类:
其他好文 时间:
2014-09-25 19:44:27
阅读次数:
201
LinkedIn 高频题 – Maximum Sum/ProductSubarrayMaximum Sum Subarray是leetcode原题,跟Gas Station的想法几乎一模一样。解答中用到的结论需要用数学简单地证明一下。123456789101112public int maxSubA...
分类:
其他好文 时间:
2014-09-25 13:16:18
阅读次数:
223
DescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately,...
分类:
其他好文 时间:
2014-09-23 22:55:45
阅读次数:
240
首先求出所有的单间两两是否接触如果接触,说明他们之间的边长为0,不接触那么就是圆心的距离减去两个单间的半径。然后构图求最小生成树,采用Kruskal算法。...
分类:
其他好文 时间:
2014-09-19 23:57:56
阅读次数:
480
原题地址:https://oj.leetcode.com/problems/gas-station/题意:There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You ha...
分类:
编程语言 时间:
2014-09-14 11:19:36
阅读次数:
221
一,vmtool安装,进入桌面就后,如果没有看到VMware Tools光盘,请点击VMware Station菜单栏上的“虚拟机”,然后选择“安装VMware Tools”,就可以在桌面上以看到VMware Tools光盘了,安装步骤为:1)把VMware Tools目录复制到备份目录下,2)解压...
分类:
系统相关 时间:
2014-09-12 16:52:03
阅读次数:
237
题意很清晰,每个加油站有一定的油,到下一个站需要消耗一定的油量,这个关系是固定的,这样我们就可以用一个数组来表示汽车到每个加油站以及接下来一段路程增加的油量,即gas[i]-cost[i]; 例如:gas 5 0 9 4 3cost 6 7 5 9 5 seq -1 -7 4 -5 -2这就变成了....
分类:
其他好文 时间:
2014-09-11 23:37:12
阅读次数:
224