hiho 1611 泡泡圖 [Offer收割]編程練習賽32 Problem A 數學公式暴力

來源:互聯網
上載者:User

大圓套小圓,針對每個圓,找出包含它的那個面積最小的圓就行了,一共1000個,複雜度n方

這個題我還WA了兩發。。。我還以為是EPS的問題,最後發現那個max值設的太小了,之前就寫了一串9,後來改成比輸入值的max大就過了。。。

#include <iostream>#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string>#include <string.h>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <stack>#include <bits/stdc++.h>using namespace std;int N;double X[1009];double Y[1009];double R[1009];const double PI=acos(-1);bool contain(double x1,double y1,double r1,double x2,double y2,double r2){    if(r1-r2<=0.0000001)return false;    double d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));    if(d+r2<=r1)return true;    return false;}int main(){    cin>>N;    double maxR=0;    for(int i=0;i<N;i++){        scanf("%lf%lf%lf",&X[i],&Y[i],&R[i]);        maxR=max(R[i],maxR);    }    double maxA=maxR*maxR*PI;    for(int i=0;i<N;i++){        int father=-1;        double curArea=maxA+10;        for(int j=0;j<N;j++){            if(i==j)continue;            if(contain(X[j],Y[j],R[j],X[i],Y[i],R[i])&&PI*R[j]*R[j]<curArea){                curArea=PI*R[j]*R[j];                father=j;            }        }        if(father==-1)cout<<0<<endl;        else cout<<father+1<<endl;    }    return 0;}////                       _oo0oo_//                      o8888888o//                      88" . "88//                      (| -_- |)//                      0\  =  /0//                    ___/`---'\___//                  .' \\|     |// './/                 / \\|||  :  |||// \//                / _||||| -:- |||||- \//               |   | \\\  -  /// |   |//               | \_|  ''\---/''  |_/ |//               \  .-\__  '-'  ___/-. ///             ___'. .'  /--.--\  `. .'___//          ."" '<  `.___\_<|>_/___.' >' "".//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |//         \  \ `_.   \_ __\ /__ _/   .-` /  ///     =====`-.____`.___ \_____/___.-`___.-'=====//                       `=---='//////     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~////               佛祖保佑         永無BUG//////


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.