给定n,m。让你用O(log(n))以下时间算出ans。 打表,推出 ans[i] = 2^(i-1) + f[i-2] 故 i奇数:ans[i] = 2^(i-1) + 2^(i-3) ... + 1; i偶数:ans[i] = 2^(i-1) + 2^(i-3) ... + 2; 故可以用等比数 ...
分类:
其他好文 时间:
2019-03-22 00:33:13
阅读次数:
118
numpy模块中的矩阵对象为numpy.matrix,包括矩阵数据的处理,矩阵的计算,以及基本的统计功能,转置,可逆性等等,包括对复数的处理,均在matrix对象中。 class numpy.matrix(data,dtype,copy):返回一个矩阵,其中data为ndarray对象或者字符形式; ...
分类:
其他好文 时间:
2019-03-21 00:40:30
阅读次数:
259
给定两个 稀疏矩阵 A 和 B,返回AB的结果。您可以假设A的列数等于B的行数。 题目地址:https://www.jiuzhang.com/solution/sparse-matrix-multiplication/#tag-other 本参考程序来自九章算法,由 @Roger 提供。 题目解法: ...
分类:
其他好文 时间:
2019-03-19 23:24:03
阅读次数:
227
问题:https://leetcode-cn.com/problems/search-a-2d-matrix-ii/ GitHub实现:https://github.com/JonathanZxxxx/LeetCode/blob/master/SearchMatrixClass.cs 思路:二分查找 ...
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which ...
分类:
其他好文 时间:
2019-03-19 15:02:26
阅读次数:
174
https://coolshell.cn/articles/8790.html 这个算法告诉我们,人的杂念越少,就越容易做出选择。 这个算法告诉我们,我们的选择标准越清晰,我们就越容易做出选择。 让你帮助你认清自己最需要的是什么,认清自己最想要的是什么,然后根据这个去做选择。 贪婪算法基本上是一种急 ...
分类:
编程语言 时间:
2019-03-19 12:04:59
阅读次数:
151
11582: Gdut Count 题目描述 Farmer John有n头奶牛.某天奶牛想要数一数有多少头奶牛,以一种特殊的方式:第一头奶牛为1号,第二头奶牛为2号,第三头奶牛之后,假如当前奶牛是第n头,那么他的编号就是2倍的第n-2头奶牛的编号加上第n-1头奶牛的编号再加上自己当前的n的三次方为自 ...
分类:
其他好文 时间:
2019-03-18 14:04:22
阅读次数:
205
Levenshtein Distance The Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein dista ...
分类:
编程语言 时间:
2019-03-18 13:35:17
阅读次数:
167
Magic Odd Square Find an n?×?n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The o ...
分类:
其他好文 时间:
2019-03-17 01:28:06
阅读次数:
178
73. Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Example 2: ...
分类:
Web程序 时间:
2019-03-16 23:38:50
阅读次数:
206