聚類演算法(層級聚類,K-Means)

#!/usr/bin/pythonimport syssys.path.append('..')import modules.similarity as sim # http://hi.baidu.com/bithigher/item/6ca6844ac29d0128fb896026 import randomwords = []blogs = []data = []def getData(file = 'blogdata.txt'): global words, map f =

相似性計算(euclidean, cosine, pearson)

#!/usr/bin/pythonfrom math import sqrtdef euclidean(v1, v2): length = min(len(v1), len(v2)) if length == 0: return 0 d = 0 for i in range(length): d += pow((v1[i] - v2[i]), 2) #return sqrt(d) return 1 / float(1+d)def

poj3140 樹狀dp

Contestants DivisionTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 7396 Accepted: 2090DescriptionIn the new ACM-ICPC Regional Contest, a special monitoring and submitting system will be set up, and students will be able to compete at

隨機最佳化演算法

對於解可以用向量或者矩陣表示的問題,可以採用隨機最佳化的演算法來求近似最優解。前提:1)解是向量或者矩陣2)最優解與其他次優解臨近演算法:隨機最佳化,爬山法,類比退火,遺傳隨機演算法:完全隨機爬山法:找到的可能是局部最優解類比退火:按機率接受更差的解遺傳:變異和交叉

hdu3480 斜率最佳化dp

DivisionTime Limit: 10000/5000 MS (Java/Others)    Memory Limit: 999999/400000 K (Java/Others)Total Submission(s): 2142    Accepted Submission(s): 851Problem DescriptionLittle D is really interested in the theorem of sets recently. There’s a problem

POJ3384+半平面交

/*給出一個凸多邊形的房間,根據風水要求,把兩個圓形地毯鋪在房間裡,不能摺疊,不能切割,可以重疊。問最多能覆蓋多大空間,輸出兩個地毯的圓心座標。多組解輸出其中一個將多邊形的邊內移R之後,半平面交地區便是可以放入圓的可列區域*/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace

acm反思1

搞acm也一年了,我也不知道這一年到底收穫了很多,真的可以說,這一年,沒有白過吧,也許,可以說,是很充實,說實話,我這樣的人,搞ACM也就是為了拿一個獎,為了一個不可達到的獎,想要衝進word final ,然而,現實中,往往,一切都不是那麼容易,一切都是那麼難,但是反過來想,如果是,那麼容易,那又有什麼用呢?這一年,做的題目類型太多了,反正,我知道的演算法,我聽過的名字,我都想全都去學,但是,在真正用的時候卻不是那麼如意,因為,題目實在是變化多端,如果,全都只是一個瞭解,真正遇見題目又做不到,

POJ1556+線段相交

/*dij+兩點間距離*/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<math.h>using namespace std;const int maxn = 205;//point numberconst int maxm = 105;//line numberconst

poj1184 聰明的打字員

L - 聰明的打字員Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64uSubmit StatusDescription阿蘭是某機密部門的打字員,她現在接到一個任務:需要在一天之內輸入幾百個長度固定為6的密碼。當然,她希望輸入的過程中敲擊鍵盤的總次數越少越好。 不幸的是,出於保密的需要,該部門用於輸入密碼的鍵盤是特殊設計的,鍵盤上沒有數字鍵,而只有以下六個鍵:Swap0, Swap1,

HDU4662+無

把目標中的 U 轉化為 I。又因為 I的個數是有規律的:1 2 4 8 16 。。。再結合可以取消 6 12 18 。。。個I。。。得解#include<string.h>#include<stdio.h>#include<iostream>#include<algorithm>#include<map>using namespace std;const int maxn =

HDU1632+半平面交

模板題題意:給定兩個凸多邊形,求出合并後的面積,這個合并後的面積不包括重疊部分。#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;const int maxn = 155;const int maxm = 155;const double eps = 1e-8;const

poj3278 Catch That Cow

Catch That CowTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 36079 Accepted: 11123DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a

POJ3207+Tarjan+2-sat

/*2-sat題意:給定一個圓,圓上一些點。兩點一線。現給出一些線,這些線可以在圓內連起來,也可以在圓外。問有沒有可能所有的線畫完 且 不出現相交。思路:把線畫在圓內或圓外

HDU4148+找規律

規律找到了就是個大水題。。S(n)是描述S(n-1)/**/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<queue>#include<map>#include<stack>#include<set>#include<math.h&g

POJ3525+半平面交

題意:求出給定的凸多邊形的內接圓#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;const int maxn = 155;const int maxm = 1005;const double Min = 0.0;const double Max = 10000000000

POJ2348+博弈

/*博弈關鍵態:較大數是較小數的2倍以上。*/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<queue>#include<map>#include<stack>#include<set>#include<math.h>using

HDU3934+凸包

題意:給定一些點,求最大三角形面積/*凸包*/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<queue>//#include<map>#include<math.h>using namespace std;typedef long long ll;//

POJ3714+最近點對

只需要特判標記即可#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;const double eps = 1e-8;const double inf = 9999999999.0;const int maxn = 100005;struct Point{double x,

zoj3659 Conquer a New Region

Conquer a New RegionTime Limit: 5 Seconds Memory Limit: 32768 KB The wheel of the history rolling forward, our king conquered a new region in a distant continent.There are N towns (numbered from 1 to N) in this region connected by several roads.

POJ2349+Prim

Prim!/*prim題意:給定一些點,一些衛星,一個衛星能串連兩個點,點和點之間通訊有一定的距離限制。問能使得所有的點聯通的最小距離。*/#include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<iostream>#include<queue>#include<map>#include<stack>

總頁數: 61357 1 .... 16823 16824 16825 16826 16827 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.