原创 用樸素貝葉斯分類算法做中文文本分類

一. 樸素貝葉斯分類算法的原理 樸素貝葉斯分類器基於屬性條件獨立假設:對於已知類別,假設所有屬性相互獨立,也就是說,假設每個屬性獨立地對分類結果產生影響。 設待分類的樣本屬性集爲TT ,其中包含nn 個屬性,分別爲t1,t2,t

原创 Logistic迴歸和梯度上升算法

一. Logistic迴歸原理 Logistic迴歸是一種廣義線性迴歸,常用的分類器函數是Sigmoid函數,其公式如下: σ(z)=11+e−z 其中,z 可由下面公式得出: z=w0x0+w1x1+w2x2+⋅⋅⋅+wn

原创 codeforces 488 D. Strip

D. Strip time limit per test 1 second memory limit per test 256 megabytes input standard input output standard

原创 codeforces 548 C. Mike and Frog

C. Mike and Frog time limit per test 1 second memory limit per test 256 megabytes input standard input output

原创 用KNN做手寫數字識別(mnist)

一. KNN的原理 KNN的主要思想是找到與待測樣本最接近的k個樣本,然後把這k個樣本出現次數最多的類別作爲待測樣本的類別。 二. 數據源 mnist數據集,包含42000張28*28的圖片,可以從網盤下載http://pan.baidu

原创 決策樹(ID3算法)

一. ID3算法原理 ID3算法通過計算每個屬性的信息增益,認爲信息增益越大屬性越優,每次劃分選取信息增益最大的屬性爲劃分標準,重複這個過程,直到構成一棵決策樹。 二. 關鍵概念 1. 信息熵 信息熵是描述事件給我們的驚訝程度,如果所有事

原创 codeforces 548 D. Mike and Feet (單調棧)

D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output

原创 hdu 5593 ZYB's Tree

ZYB's Tree    Accepts: 77    Submissions: 513  Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072

原创 The 2015 ACM-ICPC Asia Beijing Regional Contest K A Math Problem

思路: 經過分析可得: f(2 * k) = 3 * f(k) f(2 * k + 1) = 3 * f(k) + 1 然後:f(x) = 把x用二進制表示出來後,用三進制來計算得到的數值 如:x = 5時,二進制爲101,所以f

原创 codeforces 602 D. Lipshitz Sequence (單調棧)

D. Lipshitz Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input out

原创 hdu 5592 ZYB's Premutation (線段樹)

ZYB's Premutation    Accepts: 218    Submissions: 983  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 13107

原创 codeforces 602 E. Kleofáš and the n-thlon (概率dp)

E. Kleofáš and the n-thlon time limit per test 1 second memory limit per test 256 megabytes input standard input

原创 codeforces 593 C. Beautiful Function

C. Beautiful Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input o

原创 codeforces 488 E. Prefix Product Sequence

E. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input

原创 codeforces 548 E. Mike and Foam (莫比烏斯反演)

E. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard input output