思路:
求出每个圆与x轴上交点,即可转化为区间选点模型。
实现:按r排序,每次选取最右端放点。
求出每个圆与x轴上交点,即可转化为区间选点模型。
实现:按r排序,每次选取最右端放点。
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype>
#include <sstream>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <algorithm>
#define SF(a) scanf("%d", &a)
#define PF(a) printf("%d\n", a)
#define SFF(a, b) scanf("%d%d", &a, &b)
#define SFFF(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SFFFF(a, b, c, d) scanf("%d%d%d%d", &a, &b, &c, &d)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define IN() freopen("in.txt", "r", stdin)
#define OUT() freopen("out.txt", "w", stdout)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define PB push_back
#define LL long long
#define mod 10007
#define inf 1000007
#define eps 1e-5
using namespace std;
int buf[20];
int read() {
int x = 0; char ch = getchar(); bool f = 0;
while (ch < '0' || ch > '9') { if (ch == '-') f = 1; ch = getchar(); }
while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
return f ? -x : x;
}
void write(int x) {
if (!x) { putchar(48); return; }
int l = 0; if (x < 0) putchar('-'), x = -x;
while (x) buf[++l] = x % 10, x = x / 10;
while (l) putchar(buf[l--] + 48);
}
//-------------------------chc------------------------------//
const int maxn = 100000 + 5;
int D;
struct Range {
int a, b;
double l, r;
bool operator<(const Range &rhs) const {
return (r < rhs.r) || (r == rhs.r && l < rhs.l);
}
void get_range() {
double t = sqrt(D*D - b*b);
l = a - t;
r = a + t;
}
}a[maxn];
int main() {
int L;
while (~SFF(L, D)) {
int n;
SF(n);
FOR(i, 0, n) SFF(a[i].a, a[i].b), a[i].get_range();
sort(a, a + n);
int ans = 1;
double cur = a[0].r;
int i = 1;
while (1) {
while (i < n && (a[i].l <= cur && cur <= a[i].r)) ++i;
if (i >= n) break;
ans++, cur = a[i++].r;
}
PF(ans);
}
return 0;
}