和这一题构造的矩阵的方法相同。
需要注意的是,题目中a0~a9 与矩阵相乘的顺序。
#include
#include
#include
#include
#include
#define N 10
using namespace std;
int mod;
typedef long long LL;
struct matrix
{
LL a[10][10];
}...
分类:
其他好文 时间:
2014-06-16 12:06:07
阅读次数:
231
题目
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
方法
矩阵坐标的转换,循环替换。
public voi...
分类:
其他好文 时间:
2014-06-16 11:28:03
阅读次数:
199
http://poj.org/problem?id=3233
ps转:
用二分方法求等比数列前n项和:即
原理:
(1)若n==0
(2)若n%2==0
(3)若n%2==1
代码如下:
LL sum(LL p,LL n)
{
if(n==0) return 1;
i...
分类:
其他好文 时间:
2014-06-15 20:01:44
阅读次数:
210
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
思路:第一种思路是一层一层的进行旋转,比较直观,但是花费的时间要久一些;第二种思路则比较取巧,首先沿着...
分类:
其他好文 时间:
2014-06-15 08:46:26
阅读次数:
170
复杂度为o(n^3logk)
/*
求 a^k % mod,其中a是n*n的矩阵
*/
const int mod = 10000;
const int maxn = 2;
_LL k;
int n;
struct matrix
{
_LL mat[maxn][maxn];
} a,res;
matrix mul(matrix x, matrix y)
{
matrix tmp...
分类:
其他好文 时间:
2014-06-14 07:46:19
阅读次数:
206
题目
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
方法
使用两个矩阵,分别记录每一行连续的1的个数以及每一列连续的1的个数。
public int maximalRec...
分类:
其他好文 时间:
2014-06-11 00:24:51
阅读次数:
343
1 #ifndef __MAPLE_MATRIX_H__ 2 #define
__MAPLE_MATRIX_H__ 3 4 #include "maple.h" 5 6 typedef struct MATRIX{ 7 union{ 8
...
分类:
其他好文 时间:
2014-06-10 16:04:42
阅读次数:
159
题目...
二维数组中的查找,这是个简单的题,根据题意可以推出,这个二维数组其实是一个有序的一维数组。解决思路也很容易想到,每次比较每一维最后一个元素,如果该元素比要找的元素小,说明这个行不可能含该元素;如果相等,那就找到了,如果最后一个元素比要找元素大,说明该元素如果出现比在这一行。然后再在这一行中就行查找(可以用顺序,也可二分)。
代码如下:...
分类:
其他好文 时间:
2014-06-10 14:49:37
阅读次数:
233
1 #ifndef __MAPLE_MATRIX_H__ 2 #define
__MAPLE_MATRIX_H__ 3 4 #include "maple.h" 5 6 typedef struct MATRIX{ 7 union{ 8
...
分类:
其他好文 时间:
2014-06-10 10:28:48
阅读次数:
310
这部分 cover 两个比较特殊的情形,一个是 Gaussian networks,一个是
exponential family。正态分布常见的参数化策略是均值 和协方差矩阵 ,另一种是使用 information matrix/precision
matrix,即 ,另可以用所谓 potenti....
分类:
其他好文 时间:
2014-06-08 23:10:53
阅读次数:
296