algorithm'''problem solve
[백준]1002-터렛(설명X)
JunHwa Park
2019. 8. 15. 21:22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <iostream> #include <cmath> using namespace std; int main() { int input; cin >> input; for (int i = 0; i < input; i++) { int x1, y1, r1, x2, y2, r2; cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2; double length = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)); if (x1 == x2 && y1 == y2) { if (r1 == r2) cout << -1 << endl; else cout << 0 << endl; } else { if (length<r1 + r2 && length>abs(r1 - r2)) cout << 2 << endl; else if (length == r1 + r2 || abs(r1 - r2) == length) cout << 1 << endl; else cout << 0 << endl; } } } | cs |