题意:求S(k) = A+A^2+...+A^k.解法:二分即可。if(k为奇) S(k) = S(k-1)+A^kelse S(k) = S(k/2)*(I+A^(k/2))代码:#include #include #include #include #define SMod musing ...
分类:
其他好文 时间:
2014-09-09 12:28:28
阅读次数:
199
Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri...
分类:
其他好文 时间:
2014-09-09 11:38:08
阅读次数:
204
1 public class Solution { 2 public void setZeroes(int[][] matrix) { 3 int m=matrix.length; 4 int n=matrix[0].length; 5 bo...
分类:
其他好文 时间:
2014-09-09 10:38:48
阅读次数:
203
1 public class Solution { 2 public int[][] generateMatrix(int n) { 3 int num=1; 4 int [][] result = new int[n][n]; 5 6 ...
分类:
其他好文 时间:
2014-09-09 10:27:58
阅读次数:
206
public class Solution { public boolean searchMatrix(int[][] matrix, int target) { int low=0, high=matrix.length-1; while (low target)...
分类:
其他好文 时间:
2014-09-08 00:58:06
阅读次数:
347
F -BananaTime Limit:1000MSMemory Limit:30000KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionConsider a tropical forrest, represented as a matrix...
分类:
其他好文 时间:
2014-09-07 23:45:45
阅读次数:
252
public class Solution { public void rotate(int[][] matrix) { int n=matrix.length; for (int i=0; i<n/2; i++) { for (int j=i...
分类:
其他好文 时间:
2014-09-07 14:42:05
阅读次数:
159
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:
其他好文 时间:
2014-09-07 10:58:14
阅读次数:
185