Algorithm & DataStructure/Problems
[Backjoon] 동혁 피자
GeonWoo Kim
2021. 6. 6. 09:28
수학문제로 원 안에 내접할 수 있는 사각형에 대한 문제였다. 사각형의 대각선을 구해서 원의 지름과 비교하면 간단하게 풀이가 가능하다.
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
int index = 1;
while (true) {
int r, w, l;
cin >> r;
if (r == 0) break;
cin >> w >> l;
double diagonal = sqrt(w*w + l*l);
if (2*r >= diagonal) {
cout << "Pizza " << index <<" fits on the table." << "\n";
}
else {
cout << "Pizza " << index <<" does not fit on the table." << "\n";
}
index++;
}
return 0;
}