※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 13222번 문제인 Matches이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/13222
13222번: Matches
The first line of input contains an integer N (1 ≤ N ≤ 50), the number of matches on the floor, and two integers W and H, the dimensions of the box (1 ≤ W ≤ 100, 1 ≤ H ≤ 100). Each of the following N lines contains a single integer between 1 an
www.acmicpc.net
성냥갑에 들어갈 수 있는 성냥의 최대 길이의 제곱은 (너비의 제곱) * (높이의 제곱)과 같다. (피타고라스의 정리)
각 성냥의 길이의 제곱이 위에서 구한 값보다 큰지 작은지를 판단해 문제를 해결하자.
아래는 제출한 소스코드이다.
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, x, y; cin >> N >> x >> y;
x = x * x + y * y;
while (N--) {
int k; cin >> k;
if (k * k <= x) cout << "YES\n";
else cout << "NO\n";
}
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 13225 // C++] Divisors (0) | 2022.11.25 |
---|---|
[BOJ 25757 // C++] 임스와 함께하는 미니게임 (0) | 2022.11.25 |
[BOJ 13223 // C++] 소금 폭탄 (0) | 2022.11.25 |
[BOJ 13224 // C++] Chop Cup (0) | 2022.11.25 |
[BOJ 16175 // C++] General Election (0) | 2022.11.24 |