码迷,mamicode.com
首页 > 其他好文 > 详细

CSU1614:First Blood

时间:2015-05-10 20:33:26      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:csu

Description

Zuosige always has bad luck. Recently, he is in hospital because of pneumonia. While he is taking his injection, he feels extremely bored. However, clever Zuosige comes up with a new game.

Zuosige draws some circles randomly on the paper and he wants to know how many circles have no common points with others. If a circle have no common points with another circle, they must be out of each other. This is such a simple problem and can you help him?

Input

The first line contains one integer T, indicating the number of test cases.
In one test case, there are several lines.
In the first line, there are an integer N (2<=N<=100), indicating the number of circles.
In the following N lines, there are three integers xi, yi, ri (0<=|xi|, |yi|<=1000, 1<=ri<=1000), indicating the coordinates and the radius of the i-th circle.

Output

For each test case, output an integer indicating the answer.

Sample Input

2
3
1 -1 7
10 -7 5
-9 -4 1
3
6 2 8
-10 1 5
-2 2 7

Sample Output

1
0

HINT

Source


题意:求有几个圆玉其他所有圆都不想交

#include <iostream> 
#include <stdio.h> 
#include <string.h> 
#include <stack> 
#include <queue> 
#include <map> 
#include <set> 
#include <vector> 
#include <math.h> 
#include <algorithm> 
using namespace std; 
#define ls 2*i 
#define rs 2*i+1 
#define up(i,x,y) for(i=x;i<=y;i++) 
#define down(i,x,y) for(i=x;i>=y;i--) 
#define mem(a,x) memset(a,x,sizeof(a)) 
#define w(a) while(a) 
#define LL long long 
const double pi = acos(-1.0); 
#define N 50005 
#define mod 19999997 
const int INF = 0x3f3f3f3f; 
#define exp 1e-8 
  
struct node 
{ 
    int x,y,r; 
}a[105]; 
bool vis[105][105]; 
int main() 
{ 
    int i,j,k,t,n; 
    cin >> t; 
    w(t--) 
    { 
        cin >> n; 
        up(i,0,n-1) 
        scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].r); 
        mem(vis,false); 
        up(i,0,n-1) 
        { 
            up(j,0,n-1) 
            { 
                int t1 = (a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y); 
                int t2 = (a[i].r+a[j].r)*(a[i].r+a[j].r); 
                if(t1>t2) vis[i][j]=vis[j][i] = true; 
            } 
        } 
        int ans = 0,flag; 
        up(i,0,n-1) 
        { 
            flag = 0; 
            up(j,0,n-1) 
            { 
                if(i!=j && !vis[i][j]) flag = 1; 
            } 
            if(!flag) 
            ans++; 
        } 
        cout<<ans<<endl; 
    } 
  
    return 0; 
} 


CSU1614:First Blood

标签:csu

原文地址:http://blog.csdn.net/libin56842/article/details/45624045

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!