码迷,mamicode.com
首页 >  
搜索关键字:return    ( 60766个结果
一入python深似海--split
下面说说split函数的用法 def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ')#split('.',1) use '.' split one time return words def sort_words(wo...
分类:编程语言   时间:2014-06-08 18:19:21    阅读次数:336
求解一元线性同余方程组模版
解法:直接上模版。 扩展欧几里德的模版: typedef long long LL; LL ex_gcd(LL a,LL b,LL &x,LL &y) { if(b==0) { x=1; y=0; return a; } LL d=ex_gcd(b,a%b,x,y); LL t=x; x=y;...
分类:其他好文   时间:2014-06-08 16:56:35    阅读次数:228
leetcode——Add Two Numbers 两个链表表示的正整数对其求和(AC)
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:其他好文   时间:2014-06-08 15:30:28    阅读次数:227
[LeetCode] Palindrome Partitioning II [12]
题目:For example, given s = "aab", Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut 解题思路:给一个字符串,如果字符串可以划分成若干子回文字符串,返回最小的划分数量。 这个题如果还用之前求所有划分组合的循环加递归方法的话,就会得到超时的错误。这是就要考虑别的方法,动态规划倒是一个不错的方法,但是动态规划最重要的是要找到动态方程。本题的动态方程: dp[i] =...
分类:其他好文   时间:2014-06-08 14:56:58    阅读次数:257
2-SAT模版
const int maxn = 100010; int n, m; vector G[maxn*2]; bool mark[maxn*2]; int S[maxn*2], c; int a[maxn], b[maxn], sum; bool dfs(int x) { if(mark[x^1]) return false; if(mark[x]) return true; mark...
分类:其他好文   时间:2014-06-08 10:31:01    阅读次数:198
LeetCode:Spiral Matrix I II
Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, Given the following ...
分类:其他好文   时间:2014-06-07 22:57:31    阅读次数:236
php实现快速排序
"; return array_merge($left, array($key), $right);}$array = array(29,21,3,234,57,76,6,74);$result = Qsort($array);print_r($result);?>
分类:Web程序   时间:2014-06-07 21:26:05    阅读次数:186
第四章 分治策略 4.1 最大子数组问题 (减治法,别人的,拿来看看)
/** * 获得连续子数组的最大和 * * @author dfeng * */ private static long getMax(long a, long b) { return a > b ? a : b; } /** * 获得连续子数组的最大和 * * @param array ...
分类:其他好文   时间:2014-06-07 21:21:30    阅读次数:241
第四章 分治策略 4.1 最大子数组问题 (暴力求解算法)
/** * 最大子数组的暴力求解算法,复杂度为o(n2) * @param n * @return */ static MaxSubarray findMaxSubarraySlower(int[] n) { long tempSum = 0; int left = 0; int right = 0...
分类:其他好文   时间:2014-06-07 21:07:50    阅读次数:250
php二分查找
$val){ $high = $mid -1; }else { $low = $mid+1; } } return "not found";}$array = array(1,2,3,34,534,754,823,9...
分类:Web程序   时间:2014-06-07 20:59:25    阅读次数:340
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!