码迷,mamicode.com
首页 >  
搜索关键字:matrix chain multipl    ( 5757个结果
Matrix Chain Multiplication UVA 442 (栈 表达式求值)
说说: 其实这道题是栈这个数据结构最经典的运用,即表达式的求值。与一般情况不同的是,此次要求的运算数是矩阵。在整个解析表达式的过程中,无非遇到三类字符,一个是'(',另一个是‘)’,剩下的就是运算数了。首先,在遇到‘(’的时候,栈指针自动加一,并将栈顶元素的行数和列数都设置为-1,这样就不会和正常的运算数混淆了。如果遇到的是运算数,首先要判断当前的栈顶元素是否为运算数(当然,还要注意栈为空的特殊...
分类:其他好文   时间:2014-09-03 21:20:07    阅读次数:265
Rotate Image <leetcode>
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:首先左右翻转,然后按照左下,右上...
分类:其他好文   时间:2014-09-03 19:50:47    阅读次数:241
55. Set Matrix Zeroes
思路: 找到第一个 0 元素,记下其行和列。然后对其他 0 元素,分别将其投影在记下的行和列上(做标记)。遍历之后,对于所有行中的标记,将其所在列都置为 0; 对于所有列中标记,将其所在行都置为 0. (最后置标记的行和列为 0. 可含在上述步骤) 时间: O(n2), 空间 : O(1)
分类:其他好文   时间:2014-09-03 19:45:37    阅读次数:212
54. Search a 2D Matrix && Climbing Stairs (Easy)
思路: 从右上方开始,若小于 target, 则往下走;若大于 target, 对改行二分查找;若等 target, 返回 true. 思路: 斐波那契。此处用动归。 还可以使用矩阵二分乘。(剑指offer: 题9)
分类:其他好文   时间:2014-09-03 19:42:47    阅读次数:249
zoj 2316 Matrix Multiplication 解题报告
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2316题目意思:有 N 个 点,M 条 边。需要构造一个N * M 大小的矩阵A。对于 (i, j) 这个坐标点它表示,对编号为 i 这个点编号为 j 的 点与它相连...
分类:其他好文   时间:2014-09-02 19:26:25    阅读次数:182
Leetcode-Rotate Image
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-placen*n矩阵顺时针旋转90度,规律 a[i...
分类:其他好文   时间:2014-09-02 17:14:04    阅读次数:180
矩阵快速幂
poj 3070Fibonaccihttp://poj.org/problem?id=3070模板题,矩阵都给你写好了。 1 #include 2 #include 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 class Matrix { ///矩阵 5 .....
分类:其他好文   时间:2014-09-01 22:20:53    阅读次数:335
SGU 186.The Chain
看懂题就是水题。。。code#include #include using namespace std;int a[110], n, l, r, ans;int main(){ cin >> n; for (int i = 0; i > a[i]; r = n - 1; sort (a, a + n...
分类:其他好文   时间:2014-09-01 22:20:38    阅读次数:207
hdu - 4920 - Matrix multiplication(缓存优化+开挂)
题意:求两个n x n的矩阵相乘后模3的结果,n 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4920 ——>>呀呀。。 1、3层计算的for进行缓存优化,根据CPU的L1级缓存的实现原理,减少缓存的变更。如果每次都计算完一个单元格的结果再计算下一个单元格的结果,那么被乘矩阵的访问就会频繁地更新缓存,使效率很低。。 2、输入开挂,G++提...
分类:其他好文   时间:2014-09-01 21:15:36    阅读次数:252
CC150 - 11.6
Question:Given an M x N matrix in which each row and each column is sorted in ascending order, write a method to find an element. 1 package POJ; 2 3 ....
分类:其他好文   时间:2014-09-01 02:44:02    阅读次数:209
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!