Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

实在发现不了有什么错误,希望大牛们指点一二

Posted by always at 2009-05-22 16:15:04 on Problem 2253
#include<iostream>
#include<cmath>
using namespace std;


#define INF 0x7f7f7f7f


bool flag[220];
int closest[220];
double min_dist, x[220], y[220], lowcost[220], c[220][220];


int main(){
	int n, i, j, k, num = 1;
	double min_dist, minimax;
	while(cin>>n){
		if(n==0)
			break;
		for(i=1; i<=n; i++){
			cin>>x[i]>>y[i];
		}
		minimax = -1;
		memset(flag, 0, sizeof(flag));
		flag[1] = 1;
		for(i=1; i<=n; i++){
			for(j=1; j<=n; j++){
				c[i][j] = sqrt(pow((x[j]-x[i]),2) + pow((y[j]-y[i]),2));
			}
		}
		for(i=2; i<=n; i++){
			closest[i] = 1;
			lowcost[i] = c[1][i];
		}
		for(i=1; i<n; i++){
			min_dist = INF;
			j = 1;
			for(k=2; k<=n; k++){
				if(lowcost[k]<min_dist && flag[k]==0){
					min_dist = lowcost[k];
					j = k;
				}
			}
			flag[j] = 1;
			for(k=2; k<=n; k++){
				if(c[j][k]<lowcost[k] && flag[k]==0){
					lowcost[k] = c[j][k];
					closest[k] = j;
				}
			}
		}
		for(i=1; i<=n; i++){
			if(minimax < lowcost[i])
				minimax = lowcost[i];
		}
		printf("%s%d\n", "Scenario #", num++);
		printf("%s%.3f\n", "Frog Distance = ", minimax);
	}
	system("pause");
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator