HDU3920: Clear All of Them I (State compression)

Source: Internet
Author: User

Problem DescriptionAcmers have been the Earth Protector against the edevil enemy for a long time, now it's your turn to protect our home.
There are 2 * n enemies in the map. Your task is to clear all of them with your super laser gun at the fixed position (x, y ).
For each laser shot, your laser beam can reflect 1 times (must be 1 times), which means it can kill 2 enemies at one time. and the energy this shot costs is the total length of the laser path.
For example, if you are at (0, 0), and use one laser shot kills the 2 enemies in the order of (3, 4), (6, 0 ), then the energy this shot costs is 5.0 + 5.0 = 10. 00.
Since there are 2 * n enemies, you have to shot n times to clear all of them. For each shot, it is you that select two existed enemies and decide the reflect order.
Now, telling you your position and the 2n enemies 'position, to save the energy, can you tell me how much energy you need at least to clear all of them?
Note that:
> Each enemy can only be attacked once.
> All the positions will be unique.
> You must attack 2 different enemies in one shot.
> You can't change your position.

InputThe first line contains a single positive integer T (T <= 100), indicates the number of test cases.
For each case:
There are 2 integers x and y in the first line, which means your position.
The second line is an integer n (1 <= n <= 10), denote there are 2n enemies.
Then there following 2n lines, each line have 2 integers denote the position of an enemy.

All the positions integers are between-1000 and 1000.
OutputFor each test case: output the case number as shown and then print a decimal v, which is the energy you need at least to clear all of them (round to 2 decimal places ).
Sample Input

20 016 03 00 021 02 1-1 0-2 0

Sample Output
Case #1: 6.00Case #2: 4.41



Question:

The initial coordinates and target coordinates are given. If two coordinates can be shot at a time, find the shortest distance.


#include 
 
  #include 
  
   #include 
   
    #include using namespace std;#define exp 1e-8struct node{    double x,y;} o,s[50];int n;double d[50][50],dp[(1<<20)+1],os[50];double dis(node a,node b){    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int cmp(node a,node b){    return dis(a,o)
    
     exp) return dp[u];    if(!u) return 0;    int m = 0;    while(!(u&(1<
     
      

Related Article

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.