fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(0);
  7. int l, n, k, count=0;
  8. cin >> l >> n >> k;
  9. for(int i=0; i<n; i++)
  10. {
  11. int x1, y1, x2, y2;
  12. cin >> x1 >> y1 >> x2 >> y2;
  13. if(x1*x1+y1*y1<=l*l||x2*x2+y2*y2<=l*l)
  14. count++;
  15. else
  16. {
  17. int a, b, c;
  18. int deltaX=x2-x1;
  19. int deltaY=y2-y1;
  20. a=deltaY;
  21. b=-deltaX;
  22. c=y1*deltaX-x1*deltaY;
  23. if(c*c<=l*l*(a*a+b*b)&&(-c*b<=(b*b+a*a)*max(y2, y1)&&-c*b>=(b*b+a*a)*min(y2, y1)))
  24. count++;
  25. }
  26. }
  27. cout << count/k+1 << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0s 4328KB
stdin
3 5 4
2 4 5 7
1 -1 -1 1
8 10 2 7
12 3 4 2
100 100 -100 -100
stdout
1