摘要:
原题链接:http://ac.jobdu.com/problem.php?pid=1008题目描述:给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。输入:输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p。最后一行是两个数 s,t;起点s,终点t。n和m为0时输入结束。(1 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 ... 阅读全文
阅读排行榜
[LeetCode]Evaluate Reverse Polish Notation(逆波兰式的计算)
2013-12-21 00:21 by 庸男勿扰, 342 阅读, 收藏,
摘要:
原题链接:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/题目描述:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3&qu 阅读全文
[九度OJ]1078.二叉树的遍历(重建)
2013-09-14 11:47 by 庸男勿扰, 318 阅读, 收藏,
摘要:
原题链接:http://ac.jobdu.com/problem.php?pid=1078题目描述:二叉树的前序、中序、后序遍历的定义:前序遍历:对任一子树,先访问跟,然后遍历其左子树,最后遍历其右子树;中序遍历:对任一子树,先遍历其左子树,然后访问根,最后遍历其右子树;后序遍历:对任一子树,先遍历其左子树,然后遍历其右子树,最后访问根。给定一棵二叉树的前序遍历和中序遍历,求其后序遍历(提示:给定前序遍历与中序遍历能够唯一确定后序遍历)。输入:两个字符串,其长度n均小于等于26。第一行为前序遍历,第二行为中序遍历。二叉树中的结点名称以大写字母表示:A,B,C....最多26个结点。输出:输入样 阅读全文
[LeetCode]Reverse Words in a String
2014-03-09 19:02 by 庸男勿扰, 317 阅读, 收藏,
摘要:
原题链接:http://oj.leetcode.com/problems/reverse-words-in-a-string/题目描述:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes a word?A sequence of non-space ch 阅读全文
[微软实习生2014]K-th string
2014-05-17 18:32 by 庸男勿扰, 281 阅读, 收藏,
摘要:
很久之前的事情了,微软2014实习生的在线测试题,记录下来以备后用。题目描述:DescriptionConsider a string set that each of them consists of {0, 1} only. All strings in the set have the sam... 阅读全文
浙公网安备 33010602011771号