Codeforces Beta Round #2 C. Commentator problem
模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~
题目大意:
给出三个圆,求一点到这三个圆的两切线的夹角相等。
解题思路:
对于这个题来说还是有多种思路的 。只是都搞不明确~~ /害羞脸
用模拟退火来解也是一件赌人品的事。由于退火的过程设计的不合理,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的更多相关文章
- Codeforces Beta Round #2 C. Commentator problem 模拟退火
C. Commentator problem 题目连接: http://www.codeforces.com/contest/2/problem/C Description The Olympic G ...
- Codeforces Beta Round #17 A - Noldbach problem 暴力
A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...
- 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]中有多少个数 ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
随机推荐
- nyoj--1057--寻找最大数(三)(贪心)
寻找最大数(三) 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 给出一个整数N,每次可以移动2个相邻数位上的数字,最多移动K次,得到一个新的整数. 求这个新的整数的最大 ...
- hdoj--5256--序列变换(lis变形)
序列变换 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- hdoj--5562--Clarke and food(模拟)
Clarke and food Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- Nginx-虚拟主机配置问题
Nginx-虚拟主机配置问题 标签(空格分隔): linux,php,nginx,larave 这两天突然想配置lnmp环境,学习下Nginx配置结果就遇到了下边的问题 Nginx: server下的 ...
- 如何启动和关闭MySQL?(四)
分为: 图形化 命令行 方法一:在“计算机”的图标上右键,然后选择“管理”,双击“服务和应用程序”,然后选择“服务”,找到“MySQL”这个服务,然后点击“右键”,就可以进行“停止”和“重新启动”的操 ...
- 机器学习(七) PCA与梯度上升法 (下)
五.高维数据映射为低维数据 换一个坐标轴.在新的坐标轴里面表示原来高维的数据. 低维 反向 映射为高维数据 PCA.py import numpy as np class PCA: def __ini ...
- nginx旧版本升级新版本
比如我们现在所用的是 nginx 是1.4 版本,过了一段时间后我们有新的稳定版 1.6 问世,我们想升级到新的版本怎么办? 1.把新版本解压.安装,然后将 sbin/ng ...
- python shutil 模块 的剪切文件函数 shutil.movemove(src, dst),换用 os.rename(sourceFile, targetFile)
Google 一搜python 剪切文件,出来shutil 这模块,网上很多人也跟疯说shutil.move(src, dst)就是用来剪切文件的,结果一试,剪切毛线,文件都复制到另一个文件夹了,源文 ...
- BZOJ3744 Gty的妹子序列(分块+树状数组)
题意 询问区间内逆序对数 强制在线 1<=n<=50000 1<=m<=50000 题解 两个预处理f[i][j]为块i到j的逆序对数,s[i][j]前i块≤j的有多少个边角 ...
- Python3 利用POP3与smtplib进行计算机远程控制
初习,代码有不足之处,欢迎指出. 跟大家分享的是,通过发送端发送cmd命令,从而对接收端进行cmd命令的控制. #接收端代码 from poplib import POP3 import time,o ...