模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~



题目大意:

给出三个圆,求一点到这三个圆的两切线的夹角相等。





解题思路:



对于这个题来说还是有多种思路的 。只是都搞不明确~~   /害羞脸

用模拟退火来解也是一件赌人品的事。由于退火的过程设计的不合理,WA妥妥的。

事实上我也是学了一点点。还不是太明确啊~~





以下是代码:

#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <cctype>
#include <algorithm> #define eps 1e-6
#define pi acos(-1.0)
#define inf 107374182
#define inf64 1152921504606846976
#define lc l,m,tr<<1
#define rc m + 1,r,tr<<1|1
#define zero(a) fabs(a)<eps
#define iabs(x) ((x) > 0 ? (x) : -(x))
#define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))
#define clearall(A, X) memset(A, X, sizeof(A))
#define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))
#define memcopyall(A, X) memcpy(A , X ,sizeof(X))
#define max( x, y ) ( ((x) > (y)) ? (x) : (y) )
#define min( x, y ) ( ((x) < (y)) ? (x) : (y) ) using namespace std; int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}}; struct circle
{
double x,y,r;
}cir[3]; double dis(double x,double y,double xx,double yy)
{
return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}
double f(double x,double y)
{
double tmp[3];
for(int i=0;i<3;i++)
tmp[i]=dis(x,y,cir[i].x,cir[i].y)/cir[i].r; //视角一半的sin值
double ans=0;
for(int i=0;i<3;i++)
ans+=(tmp[i]-tmp[(i+1)%3])*(tmp[i]-tmp[(i+1)%3]);
return ans;
}
int main()
{
double x=0,y=0;
for(int i=0;i<3;i++)
{
scanf("%lf%lf%lf",&cir[i].x,&cir[i].y,&cir[i].r);
x+=cir[i].x/3;
y+=cir[i].y/3;
}
double step=2;
while(step>eps)
{
double tmp=f(x,y);
int tag=-1;
for(int i=0;i<4;i++)
{
double cnt=f(x+dir[i][0]*step,y+dir[i][1]*step);
if(cnt<tmp)
{
tmp=cnt;
tag=i;
}
}
if(tag==-1)
step/=2;
else
{
x=x+dir[tag][0]*step;
y=y+dir[tag][1]*step;
}
}
if(f(x,y)<eps)
printf("%.5lf %.5lf\n",x,y);
return 0;
}

Codeforces Beta Round #2 C. Commentator problem的更多相关文章

  1. Codeforces Beta Round #2 C. Commentator problem 模拟退火

    C. Commentator problem 题目连接: http://www.codeforces.com/contest/2/problem/C Description The Olympic G ...

  2. Codeforces Beta Round #17 A - Noldbach problem 暴力

    A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...

  3. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  4. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  5. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  6. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  7. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  8. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  9. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

随机推荐

  1. Android组件系列----ContentProvider内容提供者【1】

    [正文] 一.ContentProvider简单介绍: ContentProvider内容提供者(四大组件之中的一个)主要用于在不同的应用程序之间实现数据共享的功能. ContentProvider能 ...

  2. pyspark import 可以通过 --py-files

    公用函数的放到了 common.py 文件中. 通过 --py-files 可以在pyspark中可以顺利导入: pyspark --py-files lib/common.py > impor ...

  3. HTML DOM getAttribute() 方法

    http://www.w3school.com.cn/jsref/met_element_getattribute.asp

  4. Random numbers

    Most computer programs do the same thing every time they execute, given the same inputs, so they are ...

  5. Spring 注解拦截器使用详解

    Spring mvc拦截器 平时用到的拦截器通常都是xml的配置方式.今天就特地研究了一下注解方式的拦截器. 配置Spring环境这里就不做详细介绍.本文主要介绍在Spring下,基于注解方式的拦截器 ...

  6. Maven(一)之Maven入门

    一.Maven简介 Maven可以翻译为“知识的积累”.“专家”.“内行”.作为Apache组织中的一个颇为成功的开源项目,Maven主要服务于基于Java平台的项目构建.依赖管理.和项目信息管理.M ...

  7. null, undefined理解

    概述 null与undefined都可以表示"没有",含义非常相似.将一个变量赋值为undefined或null,语法效果几乎没区别. var a = undefined; // ...

  8. python3 geohash 导入错误及解决

    方法一: pip3 install  python-geohash 方法二: 1.保证 pip3 install geohash 包 2. 进入包的下载目录 /usr/local/lib/python ...

  9. caioj 1618 【动态规划】矩阵相乘的次数

    刷刷水题压压惊 低级版的能量项链 相当于复习一次中链式dp 这种合并了之后又后效性的题目 都可以用类似的方法做 #include<cstdio> #include<cstring&g ...

  10. 【VK Cup 2015 - Finals D】Restructuring Company

    [题目链接]:http://codeforces.com/problemset/problem/566/D [题意] 给你n个人; 一开始每个人都隶属于一个部门; 之后给你q个操作; 3种操作类型; ...