标签:minimax set nbsp 答案 pie min more sid ons
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 48662 | Accepted: 15490 |
Description
Input
Output
Sample Input
2 0 0 3 4 3 17 4 19 4 18 5 0
Sample Output
Scenario #1 Frog Distance = 5.000 Scenario #2 Frog Distance = 1.414
Source
/* distance撞关键字嘤嘤嘤 */ #include<iostream> #include<cstring> #include<cmath> #include<cstdio> using namespace std; int n,kse; double f[202][202],xi[202],yi[202]; double distan(int i,int j){ return sqrt((xi[i]-xi[j])*(xi[i]-xi[j])+(yi[i]-yi[j])*(yi[i]-yi[j])); } int main(){ while(scanf("%d",&n)!=EOF){ if(!n)break; memset(f,0x3f,sizeof(f)); for(int i=1;i<=n;i++){ scanf("%lf%lf",xi[i],yi[i]); // cin>>xi[i]>>yi[i]; f[i][i]=0; } for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) f[i][j]=f[j][i]=distan(i,j); for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=min(f[i][j],max(f[i][k],f[k][j])); printf("Scenario #%d\n",++kse); printf("Frog Distance = %.3f\n\n",f[1][2]); } return 0; }
double输出时最好用%f 这个题%lf 会WA
标签:minimax set nbsp 答案 pie min more sid ons
原文地址:http://www.cnblogs.com/zzyh/p/7435416.html