est

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define MAX 1001
#define IFNIT (9223372036854775808)
unsigned long long int pt[MAX][2] = { 0 };
int ptNum = 0;

/*Kruskal start*/
typedef struct Edge
{
    int p1;
    int p2;
    unsigned long long int length;
}Edge;

int parent[MAX] = { 0 };
void qsort(Edge a[], int begin, int end)
{
    if (begin >= end)return;
    int l = begin, r = end;
    Edge k = a[l];
    while (l < r)
    {
        while ((l < r) && (a[r].length >= k.length))r--;
        a[l] = a[r];
        while ((l < r) && (a[l].length <= k.length))l++;
        a[r] = a[l];
    }
    a[l] = k;
    qsort(a, begin, l - 1);
    qsort(a, l + 1, end);
}

int find(int x)
{
    if (parent[x] == x)
    {
        return x;
    }
    else
    {
        parent[x] = find(parent[x]);
        return parent[x];
    }
}
Edge edge[MAX*MAX/2] = {0};
unsigned long long int Kruskal()
{
    int cur = 0;
    for (int i = 1; i <= ptNum; i++)
    {
        for (int j = i + 1; j <= ptNum; j++)
        {
            edge[cur].p1 = i;
            edge[cur].p2 = j;
            unsigned long long int offsetY = pt[i][0] - pt[j][0];
            unsigned long long int offsetX = pt[i][1] - pt[j][1];
            edge[cur++].length = offsetY*offsetY + offsetX*offsetX;
        }
        parent[i] = i;
    }

    qsort(edge, 0, cur-1);
    unsigned long long int  result = 0;
    int count = 0;
    for (int i = 0; i < cur; i++)
    {
        int a = find(edge[i].p1);
        int b = find(edge[i].p2);
        if (a != b)
        {
            result += edge[i].length;
            parent[a] = b;
            count++;
        }
        if (count == ptNum - 1)return result;
    }

    return 0;
}
/*Kruskal end*/

/*Prim start*/
unsigned long long int map[MAX][MAX] = { 0 };
unsigned long long int Prim()
{
    int visit[MAX] = { 0 };
    unsigned long long int minDis[MAX] = { 0 };
    for (int i = 1; i <= ptNum; i++)
    {
        for (int j = i + 1; j <= ptNum; j++)
        {
            unsigned long long int offsetY = pt[i][0] - pt[j][0];
            unsigned long long int offsetX = pt[i][1] - pt[j][1];
            map[j][i] = map[i][j] = offsetY*offsetY + offsetX*offsetX;
        }
    }

    unsigned long long int result = 0;
    visit[1] = true;
    for (int i = 2; i <= ptNum; i++)
    {
        minDis[i] = map[1][i];
    }

    for (int i = 1; i < ptNum; i++)
    {
        unsigned long long int min = IFNIT;
        int minI = 0;
        for (int j = 1; j <= ptNum; j++)
        {
            if (visit[j])continue;
            if (min > minDis[j])
            {
                min = minDis[j];
                minI = j;
            }
        }

        visit[minI] = true;
        result += min;

        for (int j = 1; j <= ptNum; j++)
        {
            if ((map[minI][j] < minDis[j]) && (!visit[j]))
            {
                minDis[j] = map[minI][j];
            }
        }
    }

    return result;
}
/*Prim end*/

int main(void)
{
    freopen("input.txt", "r", stdin);
    int test_num = 0;
    scanf("%d\n", &test_num);
    for (int test_case = 1; test_case <= test_num; test_case++)
    {
        for (int i = 0; i < MAX * 2; i++)pt[0][i] = 0;
        scanf("%d\n", &ptNum);
        for (int i = 1; i <= ptNum; i++)
        {
            scanf("%d ", &pt[i][0]);
        }
        scanf("\n");
        for (int i = 1; i <= ptNum; i++)
        {
            scanf("%d ", &pt[i][1]);
        }
        double price = 0;
        scanf("\n");
        scanf("%lf\n", &price);

        //unsigned long long int finalCost = price*Prim();
        unsigned long long int finalCost = price*Kruskal();
        printf("#%d %llu\n", test_case, finalCost);
    }

    return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;

#define MAX 105

typedef struct _edge
{
    int x;
    int y;
    int w;
}edge;

edge Edge[MAX];
int T;
int N, E, Answer;
int pre[MAX];

int cmp(const edge& A, const edge& B)
{
    return A.w < B.w;
}

int find(int x)
{
    return (pre[x] == x) ? x : pre[x] = find(pre[x]);
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);

    if(x == y)
        return false;
    else
        return pre[y] = x;
}

void kruskal()
{
    for(int i = 0; i < N; i++) pre[i] = i;

    sort(Edge, Edge + E, cmp);

    for(int i = 0; i < E; i++)
    {
        if(Union(Edge[i].x, Edge[i].y) && N--)
            Answer += Edge[i].w;
    }

    for(int i = 0; i < T; i++)
        cout <<"pre["<<i<<"] = " << pre[i] << endl;

    if(N <= 1)
        cout << Answer << endl;
    else
        cout << "?" << endl;
}

int main()
{
    while(cin >> N >> E, N)
    {
   T = N;
        Answer = 0;
        for(int i = 0; i < E; i++)
        {
            cin >> Edge[i].x >> Edge[i].y >> Edge[i].w;
        }

        kruskal();
    }
}
#if 0

#include <iostream>
#include <iomanip>
#include <cstdio>

using namespace std;

#define _DEBUG 0

#define MAX 1001
#define INF 0x7fffffff

typedef struct _point
{
    unsigned long long int x;
    unsigned long long int y;
}point;

point coord[1001];

int N;
unsigned long long int graph[MAX][MAX];
unsigned long long int dist[MAX];
bool visited[MAX];
double tax;
unsigned long long int Answer;

void InitData()
{
    for(int i = 0 ; i < MAX; i++) {
        for(int j = 0; j < MAX; j++) {
            graph[i][j] = INF;
        }
        coord[i].x = 0;
        coord[i].y = 0;
        dist[i] = INF;
        visited[i] = false;
    }
}

void _CalPath()
{
    visited[1] =  true;

    for(int i = 1; i <= N; i++) {
        if(visited[i] == false && dist[i] > graph[1][i])
            dist[i] = graph[1][i];
    }

    for(int i = 1; i < N; i++) {
        int min  = INF, index;
        for(int j = 1; j <= N; j ++) {
            if(visited[j] == false && min > dist[j]) {
                min = dist[j];
                index = j;
            }
        }
#if _DEBUG
        cout << "index = " << index << endl;
#endif
        visited[index] = true;
        Answer += min;

        for(int j = 1; j <= N; j++) {
            if(visited[j] == false && dist[j] > graph[index][j])
                dist[j] = graph[index][j];
        }
    }
}

unsigned long long Dis(int s, int e)
{
    return (coord[s].x - coord[e].x) * (coord[s].x - coord[e].x) + (coord[s].y - coord[e].y) * (coord[s].y - coord[e].y);
}

int main()
{
    int T, test_case;

    freopen("input_hanaro.txt", "r", stdin);

    cin >> T;
    for(test_case = 0; test_case < T; test_case++)
    {
        InitData();
        Answer = 0;
        cin >> N;
        for(int i = 1; i <= 2 * N + 1; i++) {
            if(i == 2 * N + 1)
                cin >> tax;
            else if(i <= N)
                cin >> coord[i].x;
            else
                cin >> coord[i-N].y;
        }

        for(int i = 1; i <= N; i++) {
            for(int j = 1; j <= N; j++) {
                if(graph[i][j] != INF) continue;
                graph[i][j] = graph[j][i] = Dis(i, j);
            }
        }

#if _DEBUG
        for(int i = 1; i <= N; i++) {
            cout << i << " : " << coord[i].x << " " << coord[i].y << endl;
        }
        cout << "tax = " << tax << endl;
        for(int i = 1; i <= N; i++) {
            for(int j = 1; j <= N; j++) {
                cout << graph[i][j] << " ";
            }
            cout << endl;
        }
#endif

        _CalPath();

        Answer *= tax;

        cout << "#" << test_case+1 << " " << setiosflags(ios::fixed) << Answer << endl;
    }
}
#endif

#if 1
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define MAX 1001
#define IFNIT (9223372036854775808)
unsigned long long int pt[MAX][2] = { 0 };
int ptNum = 0;

/*Kruskal start*/
typedef struct Edge
{
    int p1;
    int p2;
    unsigned long long int length;
}Edge;

int parent[MAX] = { 0 };
void qsort(Edge a[], int begin, int end)
{
    if (begin >= end)return;
    int l = begin, r = end;
    Edge k = a[l];
    while (l < r)
    {
        while ((l < r) && (a[r].length >= k.length))r--;
        a[l] = a[r];
        while ((l < r) && (a[l].length <= k.length))l++;
        a[r] = a[l];
    }
    a[l] = k;
    qsort(a, begin, l - 1);
    qsort(a, l + 1, end);
}

int find(int x)
{
    if (parent[x] == x)
    {
        return x;
    }
    else
    {
        parent[x] = find(parent[x]);
        return parent[x];
    }
}
Edge edge[MAX*MAX/2] = {0};
unsigned long long int Kruskal()
{
    int cur = 0;
    for (int i = 1; i <= ptNum; i++)
    {
        for (int j = i + 1; j <= ptNum; j++)
        {
            edge[cur].p1 = i;
            edge[cur].p2 = j;
            unsigned long long int offsetY = pt[i][0] - pt[j][0];
            unsigned long long int offsetX = pt[i][1] - pt[j][1];
            edge[cur++].length = offsetY*offsetY + offsetX*offsetX;
        }
        parent[i] = i;
    }

    qsort(edge, 0, cur-1);
    unsigned long long int  result = 0;
    int count = 0;
    for (int i = 0; i < cur; i++)
    {
        int a = find(edge[i].p1);
        int b = find(edge[i].p2);
        if (a != b)
        {
            result += edge[i].length;
            parent[a] = b;
            count++;
        }
        if (count == ptNum - 1)return result;
    }

    return 0;
}
/*Kruskal end*/

/*Prim start*/
unsigned long long int map[MAX][MAX] = { 0 };
unsigned long long int Prim()
{
    int visit[MAX] = { 0 };
    unsigned long long int minDis[MAX] = { 0 };
    for (int i = 1; i <= ptNum; i++)
    {
        for (int j = i + 1; j <= ptNum; j++)
        {
            unsigned long long int offsetY = pt[i][0] - pt[j][0];
            unsigned long long int offsetX = pt[i][1] - pt[j][1];
            map[j][i] = map[i][j] = offsetY*offsetY + offsetX*offsetX;
        }
    }

    unsigned long long int result = 0;
    visit[1] = true;
    for (int i = 2; i <= ptNum; i++)
    {
        minDis[i] = map[1][i];
    }

    for (int i = 1; i < ptNum; i++)
    {
        unsigned long long int min = IFNIT;
        int minI = 0;
        for (int j = 1; j <= ptNum; j++)
        {
            if (visit[j])continue;
            if (min > minDis[j])
            {
                min = minDis[j];
                minI = j;
            }
        }

        visit[minI] = true;
        result += min;

        for (int j = 1; j <= ptNum; j++)
        {
            if ((map[minI][j] < minDis[j]) && (!visit[j]))
            {
                minDis[j] = map[minI][j];
            }
        }
    }

    return result;
}
/*Prim end*/

int main(void)
{
    freopen("input_hanaro.txt", "r", stdin);
    int test_num = 0;
    scanf("%d\n", &test_num);
    for (int test_case = 1; test_case <= test_num; test_case++)
    {
        for (int i = 0; i < MAX * 2; i++)pt[0][i] = 0;
        scanf("%d\n", &ptNum);
        for (int i = 1; i <= ptNum; i++)
        {
            scanf("%d ", &pt[i][0]);
        }
        scanf("\n");
        for (int i = 1; i <= ptNum; i++)
        {
            scanf("%d ", &pt[i][1]);
        }
        double price = 0;
        scanf("\n");
        scanf("%lf\n", &price);

        //unsigned long long int finalCost = price*Prim();
        unsigned long long int finalCost = price*Kruskal();
        printf("#%d %llu\n", test_case, finalCost);
    }

    return 0;
}
#endif

输入

20
2
0 0
0 100
1.0
4
0 0 400 400
0 100 0 100
1.0
6
0 0 400 400 1000 2000
0 100 0 100 600 2000
0.3
8
0 155 92 400 566 1256 964 3000
0 166 1000 10 236 778 1000 3000
0.2
9
567 5 45674 24 797 29 0 0 0
345352 5464 145346 54764 5875 0 3453 4545 123
0.0005
10
798 915 797 463 895 523 959 702 235 523
126 25 402 45 841 762 982 605 616 78
0.66

1024

时间: 2024-10-29 10:46:23

est的相关文章

38、EST序列拼接流程

转载:http://fhqdddddd.blog.163.com/blog/static/18699154201241014835362/ http://blog.sina.com.cn/s/blog_4476400f0100iq0x.html EST----对EST序列进行冗余查找,利用CD_HIT软件聚类,快速批量去除冗余序列 est-trimer(去掉帽子和尾巴,去掉太短而不可信的) RepeatMaster(去掉转座子等重复) seqclean(去除载体,线粒体叶绿体等序列) CAP3(

mac上执行sed的编辑 -i命令报错sed: 1: &quot;test.txt&quot;: undefined label ‘est.txt’或sed: 1: &quot;2a\test\&quot;: extra characters after \ at the end of a command

问题一 sed编辑命令:[sed -i 's/a/b/g' test.txt] 报错:sed: 1: "test.txt": undefined label 'est.txt' 解决方案:增加一个备份的追加名[sed -i '.bak' 's/a/b/g' test.txt] 原因:mac强制要求备份,否则报错 当然可以不使用其他备份名字,只是用’',就可以只保留一份 sed -i ‘’ ’s/a/b/g’ test.txt 问题二 sed追加命令:[sed -i '' "/

创立Est?Design华服高级成衣定制工作室 - 北京服装学院-莱佛士国际学院

创立Est?Design华服高级成衣定制工作室 - 北京服装学院-莱佛士国际学院 创立Est?Design华服高级成衣定制工作室 创立Est?Design华服高级成衣定制工作室 童雪涛   "专业成就理想.北服莱佛士国际学院的特色教育模式让我对服装行业有了更深的认识,它为我打开了无限发挥的空间." 来自浙江的童雪涛,对服装充满了无限热爱.在来到北服-莱佛士国际学院学习之前她就拥有一家自己的服装店,但那时的她对服装行业并没有太多的专业知识,只是从一个商业的角度从事着服装经营.在北服-莱佛

EST云硬盘修复系统

硬盘云维修系统:硬盘经过长时间运行, 到达无故障运行峰值后, 将不可避免的出现各种故障, 例如常见的:读写故障(一般称为坏道), 电路板故障, 固件故障, 等等.EST硬盘云维修系统, 通过云端服务器强大的处理能力, 使用智能的在线判断故障范围, 针对性地下发维修指令, 尽可能把硬盘恢复到正常工作状态. EST硬盘云维修系统, 最高可同时对多达128个设备进行维修, 通过云端服务器的精准控制, 大大提高维修效率及成功率. 试用下载:http://www.hddup.com/

Vmware esx/esxi Vlan三种配置模式(VST、EST和VGT)

在Vmwareesx/esxi中使用虚拟Lan(Vlan)时,一般是指Vlan Trunk的使用,使用的Vlan配置还有其它三种类型:Virtual Switch Tagging(虚拟交换机标记,缩写VST).External SwitchTagging(外部交换机标记,缩写EST)和Virtual Guest Tagging(虚拟guest标记,简称VGT). 那我们如今就来介绍下着三种类型的差别及用途. Virtual Switch Tagging(VST) VST採用802.1q Vlan

Est数据库

Est--编码序列,gene 片段且具有标签 其中,est数据库中是类似测序1.测序2.测序3这样的序列.实验室测得的序列是cDNA,通过上图方法拼接,电脑克隆(dbest).如果有overlap则认为两个序列来自于同一个gene,overlap的碱基数目是40(不建议低于30,不建议高于40),过少容易拼接乱,过多对碱基突变的容忍性差.就一条序列来说,将比对后延长的结果进行二次比对,以此类推,直到不能延长为止. est数据库的覆盖率超过95%. 先利用其他数据库(eg:引物数据库.末端数据库)

前段时间,接手一个项目使用的是原始的jdbc作为数据库的访问,发布到服务器上在运行了一段时间之后总是会出现无法访问的情况,登录到服务器,查看tomcat日志发现总是报如下的错误。    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected est

前段时间,接手一个项目使用的是原始的jdbc作为数据库的访问,发布到服务器上在运行了一段时间之后总是会出现无法访问的情况,登录到服务器,查看tomcat日志发现总是报如下的错误. Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too man

手把手教你用EST进行固件降级

范例型号: ST3600057SS  固件版本 EN03 为DELL EQL存储设备用的硬盘固件,像这类使用非标准扇区字节数,又或者关闭硬盘写入缓存的情况,是不能在普通PC上使用,或者表速度很慢,所以我们进行降级固件,让其能在普通PC上正常使用.

EST 云硬盘修复小工具-SAS希捷固件升级工具

自动识别硬盘,自动升级固件 点击此处下载-->