• poj 2253


    #include <stdio.h>
    #include <math.h>
    int a[220][220];
    int x[220],y[220],n;
    int init()
    { int i,j;

    for(i=0;i<n;i++)
    scanf("%d%d",&x[i],&y[i]);

    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    a[i][j]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
    }
    int Min(int x,int y)
    {
    return x<y?x:y;
    }
    int Max(int x,int y)
    {
    return x>y?x:y;
    }
    int floyd()
    { int i,j,k,t;
    for(k=0;k<n;k++)
    {
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)

    {
    t=Min(a[i][j],Max(a[i][k],a[k][j])); // i------ k------ j
    if(a[i][j]>t) a[i][j]=t;
    }
    }
    }
    int main()
    { int c=1;
    while(scanf("%d",&n),n)

    {

    init();
    floyd();
    printf("Scenario #%d Frog Distance = %.3lf ",c++,sqrt(a[0][1]));
    }
    }

    #include <iostream>
    #include <string.h>
    #include <stdio.h>
    #include <algorithm>
    #include <set>
    #include <queue>
    #include <map>
    #include <vector>
    #include <string>
    #include <math.h>
    using namespace std;
    const int MAXN=210;

    pair<int,int>p[MAXN];

    double dis(pair<int,int>p1 , pair<int,int>p2)
    {
    return sqrt((double)(p1.first-p2.first)*(p1.first-p2.first)+(p2.second-p1.second)*(p2.second-p1.second));
    }
    double dist[MAXN][MAXN];
    int main()
    {

    int n;
    int x,y;
    int iCase=0;
    while(scanf("%d",&n)==1&&n)
    {
    iCase++;
    printf("Scenario #%d ",iCase);
    for(int i=0;i<n;i++)
    {
    scanf("%d%d",&x,&y);
    p[i]=make_pair(x,y);
    }
    for(int i=0;i<n;i++)
    for(int j=i;j<n;j++)
    {
    if(i==j)dist[i][j]=dis(p[i],p[j]);
    else dist[j][i]=dist[i][j]=dis(p[i],p[j]);
    }
    for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    if(dist[i][j]>max(dist[i][k],dist[k][j]))
    dist[i][j]=max(dist[i][k],dist[k][j]);
    printf("Frog Distance = %.3f ",dist[0][1]);
    }
    return 0;
    }


    ******************************************************************************


    #include <stdlib.h>
    #include <stdio.h>
    #include <algorithm>
    #include <string.h>
    #include <queue>
    #include <math.h>
    using namespace std;
    #define Maxn 205
    #define INF 100000000.0
    double map[Maxn][Maxn];
    int n;
    void floyd()
    {
    for(int k=1;k<=n;k++)
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
    if(map[i][j]>max(map[i][k],map[k][j]))
    map[i][j]=max(map[i][k],map[k][j]); }
    }


    int main( )
    { int x[Maxn],y[Maxn];
    double w;
    int t=0;
    while(scanf("%d",&n)&&n)
    {
    t++;
    memset(map,INF,sizeof(map));

    scanf("%d%d",&x[1],&y[1]);

    map[1][1]=0;
    for(int i=2;i<=n;i++)
    {
    scanf("%d%d",&x[i],&y[i]);
    map[i][i]=0;
    for(int j=1;j<i;j++)
    {
    w=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    map[i][j]=map[j][i]=w;
    }
    }
    floyd();
    printf("Scenario #%d ",t);
    printf("Frog Distance = %.3f ",map[1][2]);
    printf(" ");
    }
    return (EXIT_SUCCESS);
    }

    min( 最大距离 )


    min( g[i][j], max(g[i][k],g[k][j] )

     


    t=max(g[i][k],g[k][j];
    g[i][j]=min( g[i][j],t )

  • 相关阅读:
    SpringCloud (Finchley版本)教程(四):断路器(Hystrix)
    SpringCloud (Finchley版本)教程(三):服务消费者(Feign)
    SpringCloud (Finchley版本)教程(二): 服务消费者(rest+ribbon)
    SpringCloud (Finchley版本)教程(一): 服务的注册与发现Eureka
    CF1392H ZS Shuffles Cards 题解
    2020杭电多校第六场题解
    2020杭电多校第五场题解
    2020杭电多校第四场题解
    Educational Codeforces Round 92 (Rated for Div. 2)题解
    D. Recover it!(模拟,数学)
  • 原文地址:https://www.cnblogs.com/2014acm/p/3905690.html
Copyright © 2020-2023  润新知