J - MaratonIME goes to the japanese restaurant (again)

J - MaratonIME goes to the japanese restaurant (again)
Nakato?
from MaratonIME, Members
After a long day of hard training, MaratonIME (マラトニメ) members decided to go to a Japanese restaurant. Yeah, we love Japanese food.

After a lot of sushi boats, when everyone was more than satisfied, they asked the sushi-man Sussushi (ススシ) for the last boat. Sussushi felt challenged and answered:

– You want one more boat? You shall have one more boat…

The sushi boat that he brought was the biggest that any contestant had ever seen. Some contestants even dare saying that was the biggest sushi boat that ever existed, exceeding the previous limit of 105 sushis made by the suhiwoman Gioza (ジョザ) in 742, in a festival for the king that year, Carlos-sama (カーロス様).

Besides that the contestants accepted the challenge, and together they managed to eat all the sushis. After that, the contestants we’re so full that they couldn’t touch each other. They couldn’t even think about programming problems. Help them find what pair of friends are touching themselves, so they can move away from each other.

The contestant are represented as circles in plane, and two contestants touch each other if the circles touch each other. It’s guaranteed that the intersection area of any two circles is null.

Input
In the first line there is a single integer, n indicating the number of contestants (2 ≤ n ≤ 1000).

Each one of the next n lines has 3 integers x i, y i e r i, the (i + 1)-th line describes the ith contestant. (x i, y i) are the coordinates of the center of the circle, and r i is the radius. ( - 104 ≤ x i, y i ≤ 104, 1 ≤ r i ≤ 2·104)

It is guaranteed that the intersection area of any two circles is null.

Output
For each pair of circles that touch each other, print in one line the indexes of these circles. The collisions can be printed in any order, the indexes of both circles can also be printed in any order.

Don’t print the collisions more than once, that means, if i intersects with j, print i j or j i, but not both.

Example
Input
3
0 0 2
5 0 3
10 10 1
Output
1 2
其实这个题挺简单的,就是找两两相切的圆
#include<bits/stdc++.h>
#include

using namespace std;
struct node
{
int x;
int y;
int e;
}con[1100];
int main()
{
int n;
cin>>n;
for(int i = 1;i<=n;i++)
{
cin>>con[i].x;
cin>>con[i].y;
cin>>con[i].e;
}
for(int i = 1;i<n;i++)
{
for(int j = i+1;j<=n;j++)
{
int dis1 = con[i].x - con[j].x;
int dis2 = con[i].y - con[j].y;
int dis = (dis1 * dis1)+(dis2 * dis2);
if(dis == (con[i].e + con[j].e)*(con[i].e + con[j].e))
{
cout<<i<<" "<<j<<endl;
}
}
}
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值