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 ...
随机推荐
- Double Vision (Unity 5.0)
Double Vision (Unity 5.0): 根据 http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter03.html ...
- iPad iOS8.0升级和Xcode 6.0.1公布了,附Xcode 6.0.1下载地址
今天上午把iPad mini升级到了iOS 8.0,升级提示须要6.7G空间,无奈仅仅好把一些大的App删掉腾冲空间,然后開始升级,3小时后最终升级成功了. 下午试着把我们的App通过xcode 5 ...
- less10 loop循环
less .loop(@counter) when (@counter > 0) { .loop((@counter - 1)); // 递归调用自身 4 3 2 1 0 width: (10p ...
- hdu_2795,线段树,单点更新
#include<iostream> #include<cstdio> #include<cstring> #define lson l,m,rt<<1 ...
- android取高度
Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int top = r ...
- java9新特性-10-语法改进:UnderScore(下划线)使用的限制
1.使用说明 在java 8 中,标识符可以独立使用“_”来命名: 但是,在java 9 中规定“_”不再可以单独命名标识符了,如果使用,会报错:
- CSS W3SCHOOLS
https://www.w3schools.com/csS/css3_buttons.asp
- ivew语法中'${}`的用法
- vue使用,问题
参考链接:https://cn.vuejs.org/v2/guide/index.html *)[Vue warn]: Error in v-on handler: "TypeError: ...
- java流1----InputStream、OutputStream、Reader、Writer
字节流和字符流 顾名思义,字节流就是操作的是字节,字符流操作的就是字符.其中字节流又可以分为字节输入流(InputStream)和字节输出流(OutputStream).同样的字符流也可以分为字符输入 ...