Frogs' NeighborhoodTime Limit:5000MSMemory Limit:10000KTotal Submissions:7237Accepted:3123Special JudgeDescription未名湖附近共有N个大小湖泊L1,L2, ...,Ln(其中包括未名湖),...
分类:
其他好文 时间:
2014-08-03 22:53:26
阅读次数:
322
问题:有序合并两个有序链表分析:归并排序的合并部分class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode *helper=new ListNode(0); ...
分类:
其他好文 时间:
2014-08-02 18:17:03
阅读次数:
170
LeetCode: Reorder List Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering ...
分类:
其他好文 时间:
2014-08-01 10:41:51
阅读次数:
224
题意:有一个公交系统的收费标准如下表:
然后问:给出 这些L1~4 & C1~4的值,然后 N个站,列出每个站的X坐标,然后询问M次,问两个站台的最小花费
题解:那么这里很明显是最短路问题,有一点的麻烦就在于建图,那么我们可以对于所有的点,用两个for循环,算出两两之间的距离,就可以得到花费是多少,同时建边,然后对于每次询问的点,我们就spfa一次就OK
#include
#inclu...
分类:
其他好文 时间:
2014-07-30 14:52:33
阅读次数:
262
1 #include 2 #include 3 #include 4 #define N 100005 5 char s1[2*N],s2[N]; 6 int next[N],l1,l2; 7 8 void get_next(char *str,int len) 9 {10 int i=...
分类:
其他好文 时间:
2014-07-30 00:46:02
阅读次数:
214
题意:有关用硬币凑成所需面值的组合数。
1、只有N,表示使用个数从1 - N的硬币凑成面值为N的组合数
2、N,L1,表示使用个数从1 - L1的硬币凑成面值为N的组合数
3、N,L1,L2,表示用个数从L1 - L2的硬币凑成面值为N的组合数
思路:这题用到了Ferrers图像的性质,即将整数N拆分成不超过n个数之和的拆分数的方案数与将整数N拆分成若干数但都不大于n的方案数是相同...
分类:
其他好文 时间:
2014-07-29 15:08:18
阅读次数:
200
题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.F....
分类:
编程语言 时间:
2014-07-26 09:51:47
阅读次数:
215
题目链接题意:将长度为L的棒子卡在墙壁之间。现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离。分析:下面的分析是网上别人的分析:设弦长为L0(即原长),弧长为L1=(1+n*C)*l0,目标值为h,半径为R,弧所对圆心角为2θ(弧度制...
分类:
其他好文 时间:
2014-07-26 00:16:26
阅读次数:
187
Reorder ListGiven a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' val...
分类:
其他好文 时间:
2014-07-22 00:16:36
阅读次数:
230
Frogs' Neighborhood
Time Limit: 5000MS
Memory Limit: 10000K
Total Submissions: 6898
Accepted: 3006
Special Judge
Description
未名湖附近共有N个大小湖泊L1, L2, ..., Ln(...
分类:
其他好文 时间:
2014-07-21 22:16:48
阅读次数:
319