fork download
  1. // i wants to take ioi
  2. //binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define int long long
  8. #define nn "\n"
  9. #define pi pair<int, int>
  10. #define fi first
  11. #define se second
  12. #define lb lower_bound
  13. #define ub upper_bound
  14. #define eb emplace_back
  15. #define pb push_back
  16. #define TASK "Haidtron"
  17.  
  18. #define ms(a, x) memset(a, x, sizeof(a))
  19. #define all(a) a.begin(), a.end()
  20. #define All(a, n) a + 1, a + 1 + n
  21.  
  22. #define LOG 19
  23.  
  24. const int INF = 1e18;
  25. const int mod = 1e9;
  26. const int N = 1e5 + 5;
  27. const int MOD = 998244353;
  28.  
  29. int bit[200000];
  30. int x, y, r, ax, ay, bx, by;
  31. void nhap(){
  32. cin >> x >> y >> r;
  33. cin >> ax >> ay >> bx >> by;
  34. }
  35. int kc2(int a, int b, int c, int d){
  36. return (a - c) * (a - c) + (b - d) * (b - d);
  37. }
  38. void solve(){
  39. int r2 = r * r;
  40. int da2 = kc2(ax, ay, x, y);
  41. int db2 = kc2(bx, by, x, y);
  42. int ab2 = kc2(ax, ay, bx, by);
  43. if(da2 <= r2 && db2 <= r2){
  44. cout << 3 << nn;
  45. return;
  46. }
  47. if(ab2 == 0){
  48. cout << 4 << nn;
  49. return;
  50. }
  51. int vx = bx - ax;
  52. int vy = by - ay;
  53. int t = (x - ax) * vx + (y - ay) * vy;
  54. int kc_tam2 = 0;
  55. if(t <= 0){
  56. kc_tam2 = da2;
  57. if(kc_tam2 > r2) cout << 4 << nn;
  58. else if(kc_tam2 == r2) cout << 1 << nn;
  59. else cout << 2 << nn;
  60. }
  61. else if(t >= ab2){
  62. kc_tam2 = db2;
  63.  
  64. if(kc_tam2 > r2) cout << 4 << nn;
  65. else if(kc_tam2 == r2) cout << 1 << nn;
  66. else cout << 2 << nn;
  67. }
  68. else{
  69. int cross = vx * (y - ay) - vy * (x - ax);
  70. int lhs = cross * cross;
  71. int rhs = r2 * ab2;
  72. if(lhs > rhs) cout << 4 << nn;
  73. else if(lhs == rhs) cout << 1 << nn;
  74. else cout << 2 << nn;
  75. }
  76. }
  77.  
  78. signed main(){
  79. if(fopen(TASK".inp", "r")){
  80. freopen(TASK".inp", "r", stdin);
  81. freopen(TASK".out", "w", stdout);
  82. }
  83. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  84. nhap();
  85. solve();
  86. return (0 ^ 0);
  87. }
Success #stdin #stdout 0s 5320KB
stdin
0 0 10
-5 -5 5 5
stdout
3