Codeforces beta round #2 C. COMMENTATOR Problem

Source: Internet
Author: User


Simulated annealing is really a very high-end thing. The idea is completely incomprehensible ~


Question:

Give three circles, and find that the two tangent angles from one point to the three circles are equal.



Solution:


There are many ideas for this question, but I cannot understand it ~~ /Shy face

Simulated annealing is also a bet, because the annealing process is not properly designed.

Actually, I learned a little bit. It's not very clear ~~



The following code is used:

# 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 () FABS (a) <EPS # define iabs (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 (, 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] ={{}, {-}, {}, {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; // The Sin value half of the angle of view is 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", & 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.