Hrbust OJ 1025 (computational geometry + approximate calculation)

Source: Internet
Author: User

This is the first time I can do so, the title of the precision range is large, so you can use the circular area directly with a small square stitching approximation to indicate that maps open the larger, more accurate, but also time-consuming and more.

The code is as follows:

#include <cstdio>#include<iostream>#include<cstring>using namespacestd;intMain () {DoubleX,y,r; intmaps[101][101],num,i,j,n;  while(~SCANF ("%d",&N)) {num=10201; memset (Maps,0,sizeof(maps));  for(intK =0; k < n;k++) {scanf ("%LF%LF%LF",&x,&y,&R); X=x* -+ -; Y=y* -+ -; R=r* -;  for(i=0; i<= -; i++)                 for(j=0; j<= -; J + +)                    if(maps[i][j]==0&& (i-x) * (i-x) + (j-y) * (j-y) <= r*R) {Maps[i][j]=1; Num--; }} printf ("%.3f\n",1.0*num/10201.0); }    return 0;}

Hrbust OJ 1025 (computational geometry + approximate calculation)

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.