백준 3063번: 게시판

danbibibi·2022년 11월 11일
0

문제

문제 바로가기> 백준 3063번: 게시판

풀이

전체 사각형의 넓이에서 겹치는 부분을 빼주었다!

#include<iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int T; cin >> T;
    int x1, y1, x2, y2, x3, y3, x4, y4, ans;
    while (T--) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        ans = (x2-x1) * (y2-y1) - (max((min(x2, x4)-max(x1, x3)), 0) * max((min(y2, y4)-max(y1, y3)), 0));
        cout << ans << "\n"; 
    }
}
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글