Last active
December 18, 2015 05:48
-
-
Save Leko/5734854 to your computer and use it in GitHub Desktop.
AOJ 0023 Circles Intersection
Time Limit : 1 sec, Memory Limit : 65536 KB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <cmath> | |
#define TIMES(i) while(i--) | |
#define REP(i, n) for ( int i = 0; i < n; i++ ) | |
using namespace std; | |
int main() { | |
int n; | |
cin >> n; | |
TIMES(n) { | |
// 入力 | |
double ax, ay, ar, bx, by, br; | |
cin >> ax >> ay >> ar >> bx >> by >> br; | |
// 距離を求める | |
double dis_x = abs(ax-bx), | |
dis_y = abs(ay-by), | |
dist = sqrt(dis_x * dis_x + dis_y * dis_y); | |
// cout << dis_x << " " << dis_y << " " << dist << endl; | |
// 離れている | |
if ( dist > ar + br ) { | |
cout << 0; | |
// aが内包されている | |
} else if ( dist + ar < br ) { | |
cout << -2; | |
// bが内包されている | |
} else if ( dist + br < ar ) { | |
cout << 2; | |
// 交わっている | |
} else { | |
cout << 1; | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment