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 ...
随机推荐
- iPad iOS8.0升级和Xcode 6.0.1公布了,附Xcode 6.0.1下载地址
今天上午把iPad mini升级到了iOS 8.0,升级提示须要6.7G空间,无奈仅仅好把一些大的App删掉腾冲空间,然后開始升级,3小时后最终升级成功了. 下午试着把我们的App通过xcode 5 ...
- iOS数据持久化 -- Core Data
Core Data是一个功能强大的层,位于SQLite数据库之上,它避免了SQL的复杂性,能让我们以更自然的方式与数据库进行交互.Core Data将数据库行转换为OC对象(托管对象)来实现,这样无需 ...
- NET下Assembly的加载过程
NET下Assembly的加载过程 最近在工作中牵涉到了.NET下的一个古老的问题:Assembly的加载过程.虽然网上有很多文章介绍这部分内容,很多文章也是很久以前就已经出现了,但阅读之后发现,并没 ...
- [AGC018 B] Sports Festival 解题报告
题目链接:https://agc018.contest.atcoder.jp/tasks/agc018_b 题目: 题目大意: 有N个人参加M个体育项目,每个人对体育项目的喜爱程度有一个排名,A[i] ...
- [HNOI2008] GT考试(DP+矩阵快速幂+KMP)
题目链接:https://www.luogu.org/problemnew/show/P3193#sub 题目描述 阿申准备报名参加 GT 考试,准考证号为 N 位数 X1,X2…Xn(0 <= ...
- luogu 3393 逃离僵尸岛
题目描述 小a住的国家被僵尸侵略了!小a打算逃离到该国唯一的国际空港逃出这个国家. 该国有N个城市,城市之间有道路相连.一共有M条双向道路.保证没有自环和重边. K个城市已经被僵尸控制了,如果贸然闯入 ...
- 5、Go if else 条件判断
package main import "fmt" func main(){ //注:在Go里面没有三元表达式”?:”,所以你只能使用条件判断语句. //示例一 if 7%2==0 ...
- tensorflow-gpu
1.Cuda 查看Cuda支持的GPU型号:https://developer.nvidia.com/cuda-gpus 下载cuda:https://developer.nvidia.com/cud ...
- div的padding和margin
原div一和div二的位置 增大div二的margin-left 增大div二的padding-top
- NodeJS学习笔记 (10)网络TCP-net(ok)
模块概览 net模块是同样是nodejs的核心模块.在http模块概览里提到,http.Server继承了net.Server,此外,http客户端与http服务端的通信均依赖于socket(net. ...