duxing201606玩游戏

版权声明:来自星空计算机团队(QQ群:134826825)——StarSky_STZG https://blog.csdn.net/weixin_43272781/article/details/86555695

http://murphyc.fun/contest/5/problem/I

Description

duxing201606喜欢看一款叫sc2的游戏,他发现在zvt时,经常会有拉狗引雷的操作,但是他自己操作不来,所有他想问问你:假设每颗雷的爆炸范围可能不一样,但是都是一个圆,只要狗走到圆内雷就会爆炸,最少需要拉几条狗引雷才能使雷全部爆炸?注意:因为两圆可能相交,所以有时候一条狗能引好几颗雷,雷和雷之间不会相互引爆.数据采用如下代码生成(rand()会产生一个0到2147483647的随机数):

2019-01-13 15-19-42屏幕截图.png

第i个雷坐标为(xi,yi),爆炸范围是ri,n为地雷数.

Input

多组测试,一个数n(n<=10).接下来n行,每行三个数x,y,z,表示坐标(x,y)和半径r

Output

最少的小狗数

Sample Input 1 

2
692314992 977213841 56
2140129659 884284570 108

Sample Output 1

2

题解:暴力解决一切问题

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
int ans,cnt,flag,temp;
struct node{
    ll x,y,r;
}e[N];
char str;
double dist(ll x,ll y,ll x2,ll y2){
    return sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));
}
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    while(~scanf("%d",&n)){
        ans=0;
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&e[i].x,&e[i].y,&e[i].r);
            flag=1;
            for(int j=1;j<i;j++){
                if(dist(e[i].x,e[i].y,e[j].x,e[j].y)<=e[i].r+e[j].r){
                    flag=0;
                    break;
                }

            }
            ans+=flag;
        }
        cout<<ans<<endl;
    }
    //scanf("%d",&t);
    //while(t--){}


    //cout << "Hello world!" << endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43272781/article/details/86555695