码迷,mamicode.com
首页 >  
搜索关键字:algorithm    ( 11758个结果)
Dijkstra算法(Java实现)
Dijkstra提出按各顶点与源点v间的路径长度的递增次序,生成到各顶点的最短路径的算法。即先求出长度最短的一条最短路径,再参照它求出长度次短的一条最短路径,依次类推,直到从源点v 到其它各顶点的最短路径全部求出为止。 下面是代码实现: package com.algorithm.impl; public class Dijkstra { private static int M = 10...
分类:编程语言   时间:2014-07-24 10:43:55    阅读次数:238
【LeetCode】【Python题解】Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on...
分类:编程语言   时间:2014-07-24 10:25:36    阅读次数:227
Java Sort算法
//插入排序:package org.rut.util.algorithm.support;import org.rut.util.algorithm.SortUtil;/*** @author treeroot* @since 2006-2-2* @version 1.0*/public clas...
分类:编程语言   时间:2014-07-24 00:53:17    阅读次数:504
Method for finding shortest path to destination in traffic network using Dijkstra algorithm or Floyd-warshall algorithm
A method is presented for finding a shortest path from a starting place to a destination place in a traffic network including one or more turn restric...
分类:Web程序   时间:2014-07-24 00:50:17    阅读次数:422
hdoj1010Starship Troopers (树状dp,依赖背包)
题目:hdoj1010Starship Troopers  题意:...
分类:其他好文   时间:2014-07-23 22:41:07    阅读次数:395
poj 3292 Semi-prime H-numbers
题目链接:http://poj.org/problem?id=3292 题目大意:就是给你一个模4余1的数H-number,如果一个H-number是H-primes 当且仅当它的因子只有1和它本身(除1外)。一个H-number是H-semi-prime当且仅当它只由两个H-primes的乘积表示。H-number剩下其他的数均为H-composite。给你一个数h,问1到h有多少个H-sem...
分类:其他好文   时间:2014-07-23 22:38:17    阅读次数:302
hdu 1258 Sum It Up(dfs)
# include # include using namespace std; int flag,t,n,a[10010],cot[10010],vis[100010]; void dfs(int x,int sum,int count) { int i; if(sum>t) return ; else if(sum==t) { for(i=0;i<count;i++)...
分类:其他好文   时间:2014-07-23 21:04:53    阅读次数:211
Topcoder SRM 628 DIV 2
被自己蠢哭了。。。。 250-point problem 国际象棋棋盘上给出两个坐标,问象从一个走到另一个最少要几步。 黑格象只能走黑格,白格象只能走白格,只要判断两个坐标的颜色是否相同就能判断是否可达,观察棋盘可以发现坐标的奇偶性决定了格子的颜色;可达的情况下最多两步就能达到,所以只要判断格子是否在同一条斜线上就行了。 #include #include #include #incl...
分类:其他好文   时间:2014-07-23 21:00:45    阅读次数:225
hdoj1561The more, The Better(树形dp,依赖背包)
题目:hdoj1561The more, The Better 题意:ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗? 分析: 分类:树形d...
分类:其他好文   时间:2014-07-23 18:05:26    阅读次数:227
POJ2549 Sumsets 折半枚举
题目大意是,一个集合中有N个元素,找出最大的S,满足条件A+B+C=S,并且这四个数都属于该集合,N不超过1000.         如果直接枚举O(n^4)显然复杂度太高,将等式转化一下A+B=S-C,此时分别对左右两边的值进行枚举,这一步复杂度为O(n ^ 2),接着就用二分法查找满足该等式的最大S值, 复杂度为O(n^2*log(n))。 #include #include #in...
分类:其他好文   时间:2014-07-23 16:39:22    阅读次数:156
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!