zoukankan      html  css  js  c++  java
  • BZOJ 3680 模拟退火

    思路:
    退火就好了……
    1.强烈建议题目名称改为“吊打出题人”
    2.这种题放oj上啥心态。。。—–hzwer

    二分TLE和WA 终于AC了……

    //By SiriusRen
    #include <cmath>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int n,XX=-100001,YY=100001;
    double l,r,w=50000,jyx,jyy;
    struct Point{double x,y,wei;}point[10050],b,ans,t;
    double dis(Point a){
        double res=0;
        for(int i=1;i<=n;i++){
            jyx=(a.x-point[i].x),jyy=(a.y-point[i].y);
            res+=sqrt(jyx*jyx+jyy*jyy)*point[i].wei;
        }return res;
    }
    int main(){
        srand(1005730820),scanf("%d",&n),ans.wei=0x3fffffff;
        for(int i=1;i<=n;i++)scanf("%lf%lf%lf",&point[i].x,&point[i].y,&point[i].wei);
        b.wei=dis(b);
        while(w>1e-4){
            for(int j=1;j<=30;j++){
                double ran=rand();
                t.x=b.x+w*sin(ran),t.y=b.y+w*cos(ran),t.wei=dis(t);
                if(t.x<XX||t.x>YY||t.y<XX||t.y>YY)continue;
                if(t.wei<b.wei)b=t;
            }
            if(b.wei<ans.wei)ans=b;
            w=w*0.9;
        }
        printf("%.3lf %.3lf
    ",t.x,t.y);
    }

    这里写图片描述

  • 相关阅读:
    srum.3
    进程调度
    Scrum 项目——1
    《构建之法》—第6-7章
    团队合作——2
    团队合作——1
    作业调度_3
    作业调度——实验2
    典型用户
    【软件工程】做汉堡包
  • 原文地址:https://www.cnblogs.com/SiriusRen/p/6532134.html
Copyright © 2011-2022 走看看