티스토리 뷰

var a,b,c,d,e,f,m,x,y:int64;
begin
x:=0;
readln(a,b);
readln(c,d);
read(e,f);

//0번 : 세개를 나열
if(a=c) and (a=e) and (a=b+d+f) then x:=1;
if(a=c) and (a=f) and (a=b+d+e) then x:=1;
if(a=d) and (a=e) and (a=b+c+f) then x:=1;
if(a=d) and (a=f) and (a=b+c+e) then x:=1;
if(b=c) and (b=e) and (b=a+d+f) then x:=1;
if(b=c) and (b=f) and (b=a+d+e) then x:=1;
if(b=d) and (b=e) and (b=a+c+f) then x:=1;
if(b=d) and (b=f) and (b=a+c+e) then x:=1;

//1번
if(a=d+f) and (c=e) and (a=b+c) then x:=1;
if(a=d+e) and (c=f) and (a=b+c) then x:=1;
if(a=c+e) and (d=f) and (a=b+d) then x:=1;
if(a=c+f) and (d=e) and (a=b+d) then x:=1;

if(b=d+f) and (c=e) and (b=a+c) then x:=1;
if(b=d+e) and (c=f) and (b=a+c) then x:=1;
if(b=c+e) and (d=f) and (b=a+d) then x:=1;
if(b=c+f) and (d=e) and (b=a+d) then x:=1;

if(c=b+f) and (a=e) and (c=d+a) then x:=1;
if(c=b+e) and (a=f) and (c=d+a) then x:=1;
if(c=a+f) and (b=e) and (c=d+b) then x:=1;
if(c=a+e) and (b=f) and (c=d+b) then x:=1;

if(d=b+f) and (a=e) and (d=c+e) then x:=1;
if(d=b+e) and (a=f) and (d=c+f) then x:=1;
if(d=a+f) and (b=e) and (d=c+e) then x:=1;
if(d=a+e) and (b=f) and (d=c+f) then x:=1;

if(e=b+d) and (a=c) and (e=f+a) then x:=1;
if(e=b+c) and (a=d) and (e=f+a) then x:=1;
if(e=a+d) and (b=c) and (e=f+b) then x:=1;
if(e=a+c) and (b=d) and (e=f+b) then x:=1;

if(f=b+d) and (a=c) and (f=e+a) then x:=1;
if(f=b+c) and (a=d) and (f=e+a) then x:=1;
if(f=a+d) and (b=c) and (f=e+b) then x:=1;
if(f=a+c) and (b=d) and (f=e+b) then x:=1;
if x=1 then write('YES') else write('NO');
end.

 

풀이 : 다중 분기 (많은 조건문)

 

3개의 직사각형을 하나의 정사각형 (square)로 만들 수 있는지를 판단하기위해 모든 경우의 수를 조건문으로 작성했습니다.

 

 

직사각형 3개로 정사각형을 만들수 있는 경우 두가지

 

0. 일렬로 세 직사각형을 나열하였을 때

1. 오른쪽 처럼 두었을 때

 

0번 조건은 먼저 각 직사각형에 길이가 모두 같은 부분이 있는지를 확인하고, 나머지 길이들의 합이, 세 직사각형이 모두 동일한 길이와 길이가 같은지를 판단하면 됩니다.

 

1번 조건은 아래의 세부조건을 전부 만족하면 됩니다.

조건 1-1 a+b = c
조건 1-2 a = a'
조건 1-3 a = b+c

 

https://www.acmicpc.net/problem/14418

 

https://www.acmicpc.net/problem/13733

 

두 문제는 동일합니다.

최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함