Another Longest Increasing Subsequence Problem 有两种思路. 思路一: 考虑到如果只有一维,那么可以用f[s]表示长度为s时,最后一个数是多少,把这个想法拓展到二维,即f[s]表示长度为s时,最后一个点的集合,也就是说有多个点,但是这多个点是有顺序,x递增,y递减,并且每次加点进来的时候,随时保持这个顺序. 关于怎么处理点的集合,可以用平衡树来实现,这里用map来代替,而且map自带二分查找的功能. 算法实现:采用二分答案的方法,初始区间是(0,an
虽然numpy数组中有argmax的函数可以获得数组的最大值的索引,但该函数获得的是numpy数组平铺后的索引,也就是一维索引.那么要怎样才能获得二维索引呢?实现很简单,比如我下面的代码: import numpy as np import math a = np.array([[1, 2, 3], [4, 5, 6]]) m, n = a.shape index = int(a.argmax()) x = int(index / n) y = index % n print(x, y) >>
一.画二维图 1.原始数据(x,y) import matplotlib.pyplot as plt import numpy as np #数据 X = np.array(list(i for i in range(6))) Y = np.array([10,30,20,50,100,120]) 2.先对横坐标x进行扩充数据量,采用linspace #插值 from scipy.interpolate import spline X_new = np.linspace(X.min(),X.ma
openGL是一个强大的底层图形库,其命令最初的时候使用C语言实现的.openGL定义了一个图形程序接口,常用于制作处理三维图像,功能强大,调用方便,在图像处理十分受欢迎. 实现图形主要使用的是openGL的一个工具包:GLUT. GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL prog