题目:It is necessary to arrange numbers from 0 to 2^(N+M)-1 in the matrix with 2^N rows and 2^M columns. Moreover, numbers occupying two adjacent cells ...
分类:
其他好文 时间:
2015-04-11 13:11:27
阅读次数:
153
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?solution:找规律 int[i]...
分类:
其他好文 时间:
2015-04-11 06:33:05
阅读次数:
121
题目:
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.
The first integer of...
分类:
其他好文 时间:
2015-04-11 00:03:23
阅读次数:
132
E. Strictly Positive MatrixYou have matrixaof sizen?×?n. Let's number the rows of the matrix from1tonfrom top to bottom, let...
分类:
其他好文 时间:
2015-04-10 22:25:42
阅读次数:
209
Problem B : Power of Matrix
Time limit: 10 seconds
Consider an n-by-n matrix A. We define Ak = A * A * ... * A (k times).
Here, * denotes the usual matrix multiplication.
You ar...
分类:
其他好文 时间:
2015-04-10 18:07:31
阅读次数:
220
题意:给出n*k的矩阵A和k*n的B,求(AB)^(n*n)结果矩阵中各元素模6 之和。(n
思路:A*B的矩阵是n*n(1000*1000)的矩阵,再快速幂肯定超时,用乘法结合律A^(N*N)
* B^(N*N) = A*B*A*B*A*B*A··· = A*(B*A)*(B*A)···,以B*A的6*6的矩阵再快速幂即可
//62MS 1716K 1968 B C++
#inclu...
分类:
其他好文 时间:
2015-04-10 13:45:56
阅读次数:
122
题意:给出矩阵的第0行(233,2333,23333,...)和第0列a1,a2,...an(n
数据范围:n,m(n ≤ 10,m ≤ 109).
思路:因为m ≤ 109
显然是要找到列与列的递推关系,用logn幂加速。
从递推式可以得知:a[i][j]可以由a[1...i][j-1] 递推得到,所以构造递推矩阵实现a[1...1][j-1]向a[1...1][j]的转移‘即可
#...
分类:
其他好文 时间:
2015-04-10 11:33:56
阅读次数:
151
problem:
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:
Integers in each row are sorted from left to right.The f...
分类:
其他好文 时间:
2015-04-09 15:30:22
阅读次数:
150
problem:
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
click to show follow up.
Follow up:
Did you use extra space?
A straight forward ...
分类:
其他好文 时间:
2015-04-09 12:00:06
阅读次数:
138
题出自https://leetcode.com/problems/rotate-image/ 内容为: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise)...
分类:
编程语言 时间:
2015-04-09 06:18:54
阅读次数:
165