Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- float absoluto(float x) {
- if (x < 0)
- return -x;
- else
- return x;
- }
- class Circulo {
- float x; float y; float r;
- public:
- Circulo(float x, float y, float r) {
- this->x = x; this->y = y; this->r = r;
- }
- int cont(Circulo* other) {
- float d_centros = sqrt( pow((this->x - other->x), 2) + pow((this->y - other->y), 2));
- if (d_centros == 0)
- return 0;
- else if (d_centros < this->r - other->r || d_centros > this->r + other->r)
- return 0;
- else if (d_centros + this->r < other->r || d_centros + other->r < this->r)
- return 0;
- else if (d_centros == this->r + other->r)
- return 1;
- else if (d_centros == absoluto(this->r - other->r))
- return 1;
- else if (d_centros < this->r + other->r)
- return 2;
- else
- return 0;
- }
- };
- int main() {
- int n;
- cin >> n;
- Circulo* c[n];
- int contador = 0;
- for (int i = 0; i < n; i++) {
- float x; float y; float r;
- cin >> x; cin >> y; cin >> r;
- c[i] = new Circulo(x, y, r);
- for (int j = 0; j < i; j++) {
- if (contador > 2*n)
- break;
- contador += c[i]->cont(c[j]);
- }
- }
- if (contador <= 2*n )
- cout << contador ;
- else
- cout << "greater";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement