Ural_scheduler. Genie bomber 2

Source: Internet
Author: User
/* I started thinking about this question last night. I saw my teammate 1y passing through quickly, which was a hit. Then I keep thinking about various situations.
Status, all kinds of debug, failed. In the afternoon, another teammate was also very quick, so he was very puzzled and asked about the search solution.
Report, the idea is to divide the 1*1 square into 1000*1000 discrete points, and then count the number of points covered by the circle. This
Method... Speechless. It is boring to find that some people will not search for problem-solving reports. They would rather waste time
If you do not do that, you can see the report indirectly. Review! */

// Copy thinking code:

# Include <iostream>
# Include <cstdio>
# Include <cstring>
# Include <cmath>

Using namespace STD;

Const int n = 11;

Struct circle {
Double X;
Double Y;
Double R;
} C [N];

Int N;

Bool in_this_circle (int I, double A, double B ){
Double TMP = SQRT (a-c [I]. x) * (a-c [I]. x) + (B-c [I]. y) * (B-c [I]. Y ));
Return TMP> C [I]. R? 0: 1;
}

Bool in_circle (double I, Double J ){
For (INT x = 0; x <n; X ++)
If (in_this_circle (x, I, j ))
Return true;
Return false;
}

Int main (){
// Freopen ("data. In", "r", stdin );

Int K, CNT;
Double I, J;

Scanf ("% d", & N );
For (k = 0; k <n; k ++)
Scanf ("% lf", & C [K]. X, & C [K]. Y, & C [K]. R );

For (CNT = 0, I = 0; I <= 1; I + = 0.001)
For (j = 0; j <= 1; j ++ = 0.001)
If (in_circle (I, j ))
CNT ++;

Printf ("% lf \ n", double (CNT)/(1000*1000) * 100 );
Return 0;
}

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.