原创 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

原创 python學習第3周(2)

#6-2 favorite_num = { "LiHua": 1, "Ben": 2, "Lili": 3, "Estin": 8, "Kimi": 6 } for name, num in favorite_num.items(): p

原创 python學習第3周(1)

#5-2 str1 = "String" str2 = "string" print(str1 == str2) print(str1 != str2) print(str1.lower() == str2.lower()) print(

原创 python學習第12周: Python matplotlib

matplotlib是一個數據可視化工具. from matplotlib import pyplot 目錄 常規繪圖方法 Exercise 常規繪圖方法 pyplot.plot(X, Y) # 繪點。 X表示點集

原创 python學習第1周(2)

#python課後作業 #2-3 name = "alice" print("Hello " + name.title() + ", it's cold today.") #2-7 name = "\n\tEinstein \n" pri

原创 python學習第6周

#11-1   city_functions.py def city_country(city, country): return (city + ", " + country).title() test_cities.py i

原创 python學習第4周(2)

#8-1 def display_message(): print("I learn function in this chapter.") display_message() #8-5 def describe_city(city_na

原创 python學習第8周(1):LeetCode45. Jump Game II題解

  題目: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each elem

原创 python學習第8周(2): LeetCode.63. Unique Paths II 題解

這是一題動態規劃的題目。若一個格子可達,則到達這個格子的路徑數等於到達其上一個格子的路徑數與到達其左格子的路徑數的和;否則到達這個格子的路徑數爲0.    題目: A robot is located at the top-left co

原创 二進制優化DP Hdu1059-Diving

多重揹包的複雜度爲O(n * m * k),其中n爲揹包總容量,m爲物品種類數,k爲一種物品的數量。實際上等價於01揹包。 二進制優化,是將一種物品的數量分解成1, 2, 4, 8, …, 2x, k-2x+1+1份並組成新的物品

原创 python學習第11周:python numpy

numpy是一個數據處理模塊,其底層是用C寫的,可以高效的對數組和矩陣進行運算。 目錄 ndarray類型 ndarray對象的創建 Exercise: ndarray類型 numpy中主要的類型,表示n-dim array。   nda

原创 期望DP POJ2096-Collecting Bugs

題意 n種bug,s個子程序。每天隨機找一個bug,允許重複。求每種bug都找到,每個程序都找到bug的期望天數 分析 這是一個期望DP,對於期望DP通常是逆向推。即用dp值表示從當前狀態到達終止狀態的期望值,然後由終止狀態推導至

原创 python學習第5周(1)

#9-3 class User(): def __init__(self, first_name, last_name, sex, country): self.first_name = first_name self.last_name

原创 python學習第2周(2)

#4-2 animals = ["dog", "cat", "pig"] for animal in animals : print("A " + animal + " would make a great pet") print("An

原创 python學習第8周(3): 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 line