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

Re:请哪位大侠把你的源代码拿出来欣赏一下,多谢!

Posted by on_pku at 2009-12-21 21:49:39 on Problem 2627
In Reply To:Re:请哪位大侠把你的源代码拿出来欣赏一下,多谢! Posted by:on_pku at 2009-12-21 21:49:02
//6266755 on_pku 2627 Accepted 712K 47MS G++ 1497B 2009-12-21 21:48:08 
#include<cstdio>
#include<queue>
#include<cmath>
#include<iostream>
using namespace std;
const int NUM = 1005;
struct Hole{
       double x;
       double y; 
       int step;
       Hole (){
            step = 0;     
       }      
}hole[NUM];
int main()
{
    int v,m;    
    queue<Hole>path;
    scanf("%d %d",&v,&m);
    double range = double(v*m*60.0);
    int count = 0;
    while(scanf("%lf %lf",&hole[count].x,&hole[count].y) != EOF)count ++;    
    hole[0].step = 1;
    path.push(hole[0]);
    while(!path.empty()){
           Hole cur = path.front();
           double dis = sqrt((cur.x-hole[1].x)*(cur.x-hole[1].x) + (cur.y-hole[1].y)*(cur.y-hole[1].y));
           if(dis <= range){hole[1].step = cur.step + 1;break;}
           path.pop();       
           for(int i = 1; i < count; i++){                   
                   if(hole[i].step == 0){
                                   dis = sqrt((cur.x-hole[i].x)*(cur.x-hole[i].x) + (cur.y-hole[i].y)*(cur.y-hole[i].y));                          
                                   if(dis <= range){
                                          hole[i].step = cur.step + 1;                          
                                          path.push(hole[i]);
                                   }            
                   }       
           }          
    }
    if(hole[1].step)printf("Yes, visiting %d other holes.\n",hole[1].step-2);
    else printf("No.\n");
    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