https://www.acmicpc.net/problem/1002
Baekjoon Online JudgeBaekjoon Online Judgewww.acmicpc.net3년전에 코딩수업 찍먹하고 그 이후로 아예 안건드렸다가 건드려본 뉴비임
비주얼 베이직은 잘 되던데 왜 틀렸습니다 뜨는지 모르겠음 ㅠ
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int t_case, x1, y1, r1, x2, y2, r2;
cin >> t_case;
for (int i = 0; i < t_case; i++)
{
cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
int distance = pow(x1 - x2, 2) + pow(y1 - y2, 2);
int substract = pow(r1 - r2, 2);
int plus = pow(r1 + r2, 2);
if (r1 == r2 && distance == 0) {
cout << "-1" << "\n";
}
else if (r1 != r2 && distance == 0) {
cout << "0" << "\n";
}
else {
if (plus == distance) {
cout << "1" << "\n";
}
else if (plus > distance && distance > substract) {
cout << "2" << "\n";
}
else
cout << "0" << "\n";
}
}
return 0;
}
pow를 갖다버린다
pow는 리턴값이 float임 이걸 int로 형변환하다가 오차발생하는 거 아닐까 - dc App