HDU 4756 Install Air Conditioning(次小生成樹)
題目大意:給你n個點然後讓你求出去掉一條邊之後所形成的最小生成樹。
比較基礎的次小生成樹吧。。。先prime一遍求出最小生成樹,在dfs求出次小生成樹。
Install Air Conditioning
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1038 Accepted Submission(s): 240
Problem Description
NJUST carries on the tradition of HaJunGong. NJUST, who keeps up the ”people-Z喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcmllbnRlZCwgaGFybW9uaW91cyBkZXZlbG9wbWVudKGxIG9mIHRoZSBlZHVjYXRpb25hbCBwaGlsb3NvcGh5IGFuZCBkZXZlbG9wcyB0aGUgobF1bml0eSwgZGVkaWNhdGlvbiwgdHJ1dGgtc2Vla2luZywgaW5ub3ZhdGlvbqGxIHNjaG9vbCBtb3R0bywgaGFzIG5vdyBiZWNvbWUgYW4gZW5naW5lZXJpbmctYmFzZWQsCiBtdWx0aWRpc2NpcGxpbmFyeSB1bml2ZXJzaXR5Ljxicj4KPGJyPgogIEFzIHdlIGFsbCBrbm93LCBOYW5qaW5nIGlzIG9uZSBvZiB0aGUgZm91ciBob3R0ZXN0IGNpdGllcyBpbiBDaGluYS4gU3R1ZGVudHMgaW4gTkpVU1QgZmluZCBpdCBoYXJkIHRvIGZhbGwgYXNsZWVwIGR1cmluZyBob3Qgc3VtbWVyIGV2ZXJ5IHllYXIuIFRoZXkgd2lsbCBuZXZlciwgaG93ZXZlciwgc3VmZmVyIGZyb20gdGhhdCBob3QgdGhpcyB5ZWFyLCB3aGljaCBtYWtlcyB0aGVtIHJlYWxseSBleGNpdGVkLiBOSlVTVKGvcyA2MHRoIGJpcnRoZGF5CiBpcyBhcHByb2FjaGluZywgaW4gdGhlIG1lYW50aW1lLCA1MCBtaWxsaW9uIGlzIHNwZW50IHRvIGluc3RhbGwgYWlyIGNvbmRpdGlvbmluZyBhbW9uZyBzdHVkZW50cyBkb3JtaXRvcmllcy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yBhY2NvcmRpbmcgdG8gdGhlIG1pbmltdW0gc3RyYXRlZ3kgZGVzY3JpYmVkIGFib3ZlLCBob3cgbXVjaCBjb3N0IGF0IG1vc3QgeW91"ll spend?
Input
The first line of the input contains a single integer T(T ≤ 100), the number of test cases.
For each case, the first line contains two integers n(3 ≤ n ≤ 1000), k(1 ≤ k ≤ 100). n represents n-1 dormitories and one power plant, k represents the cost of high-load wire per meter. n lines followed contains two integers x, y(0 ≤ x, y ≤ 10000000), representing
the location of dormitory or power plant. Assume no two locations are the same, and no three locations are on a straight line. The first one is always the location of the power plant.
Output
For each case, output the cost, correct to two decimal places.
Sample Input
2
4 2
0 0
1 1
2 0
3 1
4 3
0 0
1 1
1 0
0 1
Sample Output
9.66
9.00
#include
#include