题意:给出含N个数的序列,要求把这N个数按从大到小的顺序顺时针填入m*n的矩阵中,m,n需满足m*n=N,同时m>=n且m-n尽量小。 思路:我是按如下的方式,先从左往右把第1层填满,然后从第2层到倒数第2层把最右侧填满。。。 然后设置flag来标记当前是第几圈,因为每一圈上下左右边界是变化的,如第 ...
分类:
其他好文 时间:
2018-08-29 20:04:27
阅读次数:
155
NumPy是一个关于矩阵运算的库,熟悉Matlab的都应该清楚,这个库就是让python能够进行矩阵话的操作,而不用去写循环操作。 下面对numpy中的操作进行总结。 numpy包含两种基本的数据类型:数组和矩阵。 数组(Arrays) Numpy有许多的创建数组的函数: 数组索引(Array in ...
分类:
其他好文 时间:
2018-08-29 10:41:16
阅读次数:
157
Diagonal Traverse https://www.youtube.com/watch?v=uj65eeIScnQ Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix ... ...
分类:
其他好文 时间:
2018-08-28 21:57:49
阅读次数:
145
Chiaki has an n × m matrix A. Rows are numbered from 1 to n from top to bottom and columns are numbered from 1 to m from left to right. The element in ...
分类:
其他好文 时间:
2018-08-27 23:21:36
阅读次数:
233
Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the ave ...
分类:
其他好文 时间:
2018-08-27 14:08:42
阅读次数:
225
题目描述 给定一个 n × n 的二维矩阵表示一个图像。 将图像顺时针旋转 90 度。 说明: 你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。 示例 1: 示例 2: 解题思路 分为两步: 代码 ...
分类:
其他好文 时间:
2018-08-27 12:38:16
阅读次数:
176
问题思考: 在二维数组的时候就不能用数组名表达数组首元素了。matrix不再代表数组首元素的地址。 数组类型: int array[5]的类型为int[5],而不是int型。int[5]说明这个数组有5个元素,每个元素类型是int。 定义数组类型: 数组指针: 数组类型和数组指针示例: 第15行的类 ...
分类:
编程语言 时间:
2018-08-27 01:05:08
阅读次数:
226
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2023 题意: 对于一个R行C列的正整数矩阵(1≤R,C≤20),设Ai为前i行所有元素之和,Bi ...
分类:
其他好文 时间:
2018-08-26 20:50:49
阅读次数:
197
This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the fi ...
分类:
其他好文 时间:
2018-08-26 20:07:30
阅读次数:
207
不能不计算重复情况,用容斥原理 避免了二维容斥 部分分: m=1 ans=1; m=2 ans=3^n-2; 每一行有三种情况,第一个是黑,第二个是黑,两个全是黑,减去一行全是白一行全是黑的两种情况... n,m<=5 搜索; n,m<=6 打表; 要注意的是,不要用if(!i&1) ...
分类:
其他好文 时间:
2018-08-26 20:05:55
阅读次数:
116