Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
没人贴代码真的不科学……我来贴一个#include <iostream> #include <iomanip> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; struct Node { long long x,y,step; }; Node data[210]; int queue[20010]; long long dis(const Node & a, const Node & b) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } int main(int argc, const char * argv[]) { int n;scanf("%d",&n); for(int i=1;n>0;i++,scanf("%d",&n)) { for(int j=0;j<n;j++) { scanf("%lld%lld",&data[j].x,&data[j].y); data[j].step=-1; } queue[0]=0; int head,tail; for(head=0,tail=1;head<tail;head++) { for(int j=0;j<n;j++) { long long tmp=max(data[queue[head]].step,dis(data[j],data[queue[head]])); if(data[j].step==-1) { data[j].step=tmp; queue[tail++]=j; } else { if(data[j].step>tmp) { data[j].step=tmp; queue[tail++]=j; } } } } printf("Scenario #%d\nFrog Distance = %.3f\n\n",i,sqrt((double)data[1].step)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator