ACM-ICPC North America Qualifier Human Cannonball Run

Source: Internet
Author: User

Test instructions: In a two-dimensional plane, the speed of a person walking is 5m/s, there are n cannons in the plane, the range is fixed to 50m and the time is 2 seconds, ask you the shortest time.

Problem-solving ideas: the shortest circuit

Problem Solving Code:

1 //File name:e.cpp2 //Author:darkdream3 //Created time:2015 March 14 Saturday 16:47 54 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long -  - using namespacestd; - Doublemp[ $][ $]; - structnode{ in   Doublex, y; -}dapao[ $],be,en; to intN; + DoubleDisDoubleX1,DoubleX2,DoubleY1,Doubley2) - { the    returnsqrt ((x1-y1) * (x1-y1) + (x2-y2) * (x2-y2)); * } $ Doublemi;Panax Notoginseng intMain () { -scanf"%LF%LF",&be.x,&be.y); thescanf"%LF%LF",&en.x,&en.y); +  Ami = Dis (BE.X,BE.Y,EN.X,EN.Y)/5; thescanf"%d",&n); +     -dapao[n+1].x =en.x; $dapao[n+1].Y =EN.Y; $     for(inti =1; I <= N;i + +) -    { -scanf"%LF%LF",&dapao[i].x,&dapao[i].y); the    } -     for(intI=1; I <= N;i + +)Wuyi    { the        for(intj =1; J <= n+1; J + +) -       { Wu          Doubletmp; -MP[I][J] =dis (dapao[i].x,dapao[i].y,dapao[j].x,dapao[j].y); AboutTMP =2+ Fabs (50.0-MP[I][J])/5 ; $Mp[i][j] = min (mp[i][j]/5, TMP); -       } -    } -     for(intk=1; k <= N;k + +) A    { +       for(inti =1; I <= N;i + +) the      { -         for(intj =1; J <= N +1; j + +) $Mp[i][j] = min (Mp[i][j],mp[i][k] +mp[k][j]); the      } the    } the     for(inti =1; I <= N;i + +) the    { -mi = min (Mi,dis (BE.X,BE.Y,DAPAO[I].X,DAPAO[I].Y)/5+mp[i][n+1]);  in    } theprintf"%f\n", MI); the return 0; About}
View Code

ACM-ICPC North America Qualifier Human Cannonball Run

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.