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

来源:互联网 发布:淘宝管控记录是干吗的 编辑:程序博客网 时间:2024/06/05 07:33

题目大意

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

题解

求一下圆心到原点距离,然后加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;}
原创粉丝点击