原创 樹狀DP UVa1218-Perfect Service
樹狀DP就是在樹上的DP,指當前節點的解可以通過子孫節點的解求出,即狀態轉移方程是由子孫節點推出當前節點的。 使用遍歷方法:由於樹的一個特性,即任意兩個節點之間只有一條路徑,因此深搜時每個點只會訪問一次,所以我們通常使用深搜來遍歷,這時複
原创 CodeForces - 617E 前綴異或和+莫隊算法
問題描述: E. XOR and Favorite Number Bob has a favorite number k and ai of length n. Now he asks you to answer m queries. E
原创 第六週第一次作業
#11-1city_functions.py def city_country(city, country): return (city + ", " + country).title() test_cities.py import
原创 第15周:sklearn
Question:1 datasets.make_classification是一個智能生成數據集的函數from sklearn import datasets dataset = datasets.make_classification
原创 第八週 LeetCode.63. Unique Paths II 題解
這是一題動態規劃的題目。若一個格子可達,則到達這個格子的路徑數等於到達其上一個格子的路徑數與到達其左格子的路徑數的和;否則到達這個格子的路徑數爲0. 題目:A robot is located at the top-left corner
原创 十二週 Python matplotlib
11.1題目 題解import matplotlib.pyplot as plt import numpy import math def func(x): y1 = numpy.sin(x-2) y2 = math.e
原创 第十三週:scipy
10.1題目 題解import numpy from scipy.linalg import lstsq #10.1 least square m = 20 n = 10 A = numpy.random
原创 第十一週:python numpy
Problem:Generate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A 2 Rn×m and B 2 Rm×m, for n = 2
原创 第五週第一次作業
#9-3class User(): def __init__(self, first_name, last_name, sex, country): self.first_name = first_name
原创 第八週:LeetCode45. Jump Game II題解
題目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element i
原创 第五週第二次作業
#10-1with open(r'learning_python.txt') as file_object: #line for line in file_object: print(line.rstrip
原创 第14周 : Anscombe's quartet
about Anscombe's quartet1973年,統計學家F.J. Anscombe構造出了四組奇特的數據。它告訴人們,在分析數據之前,描繪數據所對應的圖像有多麼的重要。這四組數據中,x值的平均數都是9.0,y值的平均數都是7.
原创 第四周第二次作業
#8-1def display_message(): print("I learn function in this chapter.")display_message()#8-5def describe_
原创 第九周LeetCode 120. Triangle題解
#120題目來源:https://leetcode.com/problems/triangle題目分析:Given a triangle, find the minimum path sum from top to bottom. Eac
原创 第八週 LeetCode 11. Container With Most Water
題目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines