码迷,mamicode.com
首页 >  
搜索关键字:abs problem    ( 43112个结果
2014 Super Training #2 F The Bridges of Kolsberg --DP
原题:UVA 1172 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3613动态规划问题。定义: dp[i] = 右岸前i个村庄(m岸)能够与左岸(n岸)...
分类:其他好文   时间:2014-07-07 17:13:26    阅读次数:260
Problem Linked List Cycle II
Problem Description:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without u...
分类:其他好文   时间:2014-07-07 17:00:35    阅读次数:161
Problem Path Sum II
Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>...
分类:其他好文   时间:2014-07-07 16:59:12    阅读次数:169
Problem Evaluate Reverse Polish Notation
Problem Description:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integ...
分类:其他好文   时间:2014-06-30 14:32:54    阅读次数:151
POJ 2391Ombrophobic Bovines(二分+最短路+网络流之最大流)
题目地址:http://poj.org/problem?id=2391 这个题WA了一晚上,原因是数组开小了,然后又TLE了一天,原因是数组改的过大了。。。。不多说什么了。。。 思路不难,建图也不难,二分时间,然后把每个田地之间的最短距离用floyd最短路求出来。然后建立一个源点与汇点,将田地拆分成两个点,在距离之内的进行连边,要单向连边。然后将源点与田地相连,权值为每个田地的牛的数目,再把另...
分类:其他好文   时间:2014-06-30 08:23:24    阅读次数:245
poj 2142 The Balance 扩展欧几里得
首先求出通项 X=x+b/d*t Y=y-a/d*t (x,y为ax+by=gcd(a,b)的解,d=gcd(a,b))可知我们要求的最小的解是 abs(x+b/d*t) + abs(y-a/d*t) 设a>b不是的话,就交换a,b,我们发现上述关于t的方程是 |x+k1*t| + |y-k2*t|,由于a>b所以k2>k1,所以方程一开始右边减小的比左边增加的快 所以当y=k2*t的时候...
分类:其他好文   时间:2014-06-30 07:49:37    阅读次数:244
N-Queens II
题目 Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. 方法 和上题方法一样,使用回溯法,结构基本相同,只需要返回数量。 public i...
分类:其他好文   时间:2014-06-30 06:24:22    阅读次数:273
HDOJ 1914 The Stable Marriage Problem
rt 稳定婚姻匹配问题 The Stable Marriage Problem Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 438    Accepted Submission(s): 222 Proble...
分类:其他好文   时间:2014-06-30 00:35:18    阅读次数:257
N-Queens
题目 The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-que...
分类:其他好文   时间:2014-06-30 00:34:18    阅读次数:188
POJ 2442 Sequence【堆】
题目链接:http://poj.org/problem?id=2442 题目大意:给出一个m*n的矩阵,从每一行中取出一个数相加,能得到n^m个不同的结果,要求输出其中前n项。 建立一个以n元数组为底层数组的堆,在这里,利用stl中的make_heap,pop_heap,push_heap等函数解决。 1.将第一组数据输入arr1数组,升序排序。 2.将接下来的数据输入到arr2数组中,并...
分类:其他好文   时间:2014-06-29 23:25:31    阅读次数:259
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!