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
题意:求两个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
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
Spiral Matrix
Total Accepted: 12721 Total
Submissions: 62094My Submissions
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For ex...
分类:
其他好文 时间:
2014-08-31 17:19:01
阅读次数:
210
Spiral Matrix II
Total Accepted: 12773 Total
Submissions: 41526My Submissions
Given an integer n, generate a square matrix filled with elements from 1 to n2 in
spiral order.
For exampl...
分类:
其他好文 时间:
2014-08-31 17:17:11
阅读次数:
128
这也是当初卡了很久的一道题题意:从左上角的格子出发选一条路径到右上角然后再回到左上角,而且两条路径除了起点和终点不能有重合的点。问所经过的格子中的最大和是多少状态设计:我们可以认为是从左上角出发了两条路径,然后同时到达右下角。容易看出,第k个阶段所有可能到达的格子构成一条斜线而且满足x1 + y1 ...
分类:
编程语言 时间:
2014-08-31 10:24:31
阅读次数:
260
题意:给定一个 n * n 的二维图像,将该图像顺时针旋转 90 度
思路:
先沿副对角线翻转一次,再沿水平中线翻转一次
复杂度:时间O(n^2),空间O(1)
void rotate(vector<vector > &matrix){
int n = matrix.size();
//沿副对角线翻转
for(int i = 0; i < n; ++i){
for(int j = 0; j < n - i; ++j){
int i2 = n - 1 - j, j2 = n - ...
分类:
其他好文 时间:
2014-08-30 16:29:09
阅读次数:
182
Problem Description
Sudoku is a popular single player game. The objective is to fill a 9x9 matrix with digits so that each column, each row, and all 9 non-overlapping 3x3 sub-matrices contain all o...
分类:
其他好文 时间:
2014-08-30 11:18:09
阅读次数:
286
class Solution: # @param matrix, a list of lists of integers # RETURN NOTHING, MODIFY matrix IN PLACE. def setZeroes(self, matrix): di...
分类:
其他好文 时间:
2014-08-29 16:00:48
阅读次数:
203