What about POJ 2420 A Star not a Tree? (Simulated Annealing)

Source: Internet
Author: User

What about POJ 2420 A Star not a Tree? (Simulated Annealing)

Address: POJ 2420

I encountered this question during the competition today .. So I learned simulated annealing at the site ....

This problem is first initialized to a point, and then the point is always closer and shorter. It's quite simple ..

The Code is as follows:

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #include 
      
       #include 
       
        #include 
        
         #include 
         #include 
          
           #include using namespace std;#define LL __int64const int INF=0x3f3f3f3f;int n;struct point{ int x, y;}dian[200];double dist(point a, point b){ return sqrt((a.x-b.x)*(a.x-b.x)*1.0+(a.y-b.y)*(a.y-b.y));}double juhe(point x){ int i; double z=0; for(i=0;i
           
            0.2) { flag=1; while(flag) { flag=0; point now; now.x=st.x+step; now.y=st.y; s=juhe(now); if(d>s) { flag=1; d=s; ed=now; } now.x=st.x-step; now.y=st.y; s=juhe(now); if(d>s) { flag=1; d=s; ed=now; } now.x=st.x; now.y=st.y+step; s=juhe(now); if(d>s) { flag=1; d=s; ed=now; } now.x=st.x; now.y=st.y-step; s=juhe(now); if(d>s) { flag=1; d=s; ed=now; } if(flag) st=ed; } step/=2.0; } printf("%.0f\n",d); return 0;}
           
          
        
       
      
     
    
   
  
 


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.