Codeforces Round #430 (Div. 2) - B
题目链接:http://codeforces.com/contest/842/problem/B
题意:给定一个圆心在原点(0,0)半径为r的大圆和一个圆内的圆环长度d,然后给你n个小圆,问你有多少个小圆完全位于圆环中
思路:求出每个小圆的圆心和原点的距离dist。 如果满足dist[i]-r[i]>=(r-d)&&dist[i]+r[i]<=r,说明这个小圆完全位于圆环。
#define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<stdio.h> #include<queue> #include<vector> #include<stack> #include<map> #include<set> #include<time.h> #include<cmath> #include<sstream> #include<assert.h> using namespace std; typedef long long int LL; const int inf = 0x3f3f3f3f; const LL INF = 0x3f3f3f3f3f3f3f3fLL; const int MAXN = 1e5 + 24; int main(){ //#ifdef kirito // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); //#endif // int start = clock(); int R,d,n,x,y,r; while (~scanf("%d%d",&R,&d)){ scanf("%d", &n); int ans = 0; for (int i = 1; i <= n; i++){ scanf("%d%d%d", &x, &y, &r); double dist = sqrt(1.0*x*x + 1.0*y*y); if ((dist-r) >= (R - d) && (dist+r) <= R){ ans++; } } printf("%d\n", ans); } //#ifdef LOCAL_TIME // cout << "[Finished in " << clock() - start << " ms]" << endl; //#endif return 0;