fork(4) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdio>
  4. #include <map>
  5. #include <set>
  6. #include <queue>
  7. #include <stack>
  8. #include <vector>
  9. #include <string>
  10. #include <ctime>
  11. #include <cassert>
  12. #include <algorithm>
  13. #include <cmath>
  14.  
  15. //#include <unordered_set>
  16. //#include <unordered_map>
  17.  
  18. #define forn(i, n) for (int i = 0; i < int(n); i++)
  19. #define for1(i, n) for (int i = 1; i < int(n); i++)
  20. #define forft(i, from, to) for (int i = int(from); i < int(to); i++)
  21. #define forr(i, n) for (int i = int(n) - 1; i >= 0; i--)
  22. #define X first
  23. #define Y second
  24. #define mp make_pair
  25. #define pb push_back
  26. #define sz(a) int(a.size())
  27. #define all(a) a.begin(), a.end()
  28. #define ms(a, v) memset(a, v, sizeof(a))
  29. #define correct(x, y, n, m) (x >= 0 && x < n && y >= 0 && y < m)
  30.  
  31. using namespace std;
  32.  
  33. template<typename T> T sqr(const T &x) {
  34. return x * x;
  35. }
  36.  
  37. typedef long long ll;
  38. typedef long long li;
  39. typedef pair<int, int> pt;
  40. typedef long double ld;
  41. typedef pair<ld, ld> pd;
  42.  
  43. const int INF = int(1e9);
  44. const ll INF_LL = ll(4e18);
  45. const ll INF64 = ll(4e18);
  46. const ll LINF = ll(4e18);
  47. const ld EPS = 1e-9;
  48. const ld PI = 3.14159265358979323846264338;
  49.  
  50. int r, d;
  51. int n;
  52.  
  53. bool read() {
  54. scanf("%d%d%d", &r, &d, &n);
  55. return true;
  56. }
  57.  
  58. void solve() {
  59. int ans = 0;
  60.  
  61. forn(i, n) {
  62. int x, y, cr;
  63. scanf("%d%d%d", &x, &y, &cr);
  64.  
  65. if (sqr(li(x)) + sqr(li(y)) <= sqr(li(r - cr)) && 2 * cr <= d && sqr(li(x)) + sqr(li(y)) >= sqr(li(r - d + cr))) {
  66. ++ans;
  67. }
  68. }
  69.  
  70. printf("%d\n", ans);
  71. }
  72.  
  73. int main() {
  74. srand((int) time(NULL));
  75. cout << setprecision(10) << fixed;
  76.  
  77. read();
  78. solve();
  79.  
  80. cerr << clock() << endl;
  81.  
  82. return 0;
  83. }
Success #stdin #stdout #stderr 0s 16064KB
stdin
Standard input is empty
stdout
0
stderr
2870