计算出圆心到原点的距离以后 加减 圆的半径,跟圆环的内外半径比较就好了
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <ctype.h>
#include <vector>
#include <algorithm>
#include <sstream>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
using namespace std;
typedef long long ll;
const int maxn = 500 + 7, INF = 0x3f3f3f3f, mod = 1e9 + 7;
int r1, d, r2, n;
double dd(int x, int y) {
return sqrt(x*x + y*y);
}
int main() {
scanf("%d %d%d", &r1, &d, &n);
r2 = r1 - d;
int ans = 0, x, y;
double rr;
for(int i = 0; i < n; ++i) {
scanf("%d%d%lf", &x, &y, &rr);
double t = dd(x, y);
if(t-rr >= r2 && t+rr <= r1) ans++;
}
cout << ans << endl;
return 0;
}