您的位置:首页 > 其它

Codeforces Round #430 (Div. 2) B. Gleb And Pizza

2017-08-30 14:57 435 查看

题目大意

有多少圆在外面圆内里面圆外。

题解

求一下圆心到原点距离,然后加r减r判断即可。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int read()
{
char ch=getchar();int f=0;
while(ch<'0'||ch>'9') ch=getchar();
while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
return f;
}
int d,R;
int main()
{
int n,ans=0;
d=read(),R=d-read();
n=read();
for(int i=1;i<=n;i++)
{
double x,y,r;
scanf("%lf%lf%lf",&x,&y,&r);
double len=sqrt(x*x+y*y);
if(len-r>=R&&len+r<=d)
ans++;
}
cout<<ans;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: