Pascal/BAEKJOON

pascal 24765번 Mia (백준)

rofn123 2025. 9. 1. 12:03
var a,b,c,d:word;
begin
repeat
read(a,b,c,d);
if a+b+c+d=0 then break;
if a+b=3 then a:=0
else if a<>b then if a>b then a:=90-a*10-b else a:=90-b*10-a
else a:=7-a;
if c+d=3 then c:=0
else if c<>d then if c>d then c:=90-c*10-d else c:=90-d*10-c
else c:=7-c;

if a=c then writeln('Tie.') 
else begin
 if a<c then a:=1 else a:=2;
 writeln('Player ',a,' wins.');
end;
until 1=0;
end.

 
풀이 : 구현, 많은 조건 분기
 
입력받은 값에 대해서 문제 조건에 맞추어 tier를 부여한 다음,
tier가 같다면 Tie.
다르다면 더욱 tier 숫자가 낮은 쪽이 이겼다고 출력했습니다.
 
1,2    2,1 => 0
6 6 => 1
5 5 => 2
4 4 =>3
3 3 =>4
2 2 =>5
1 1 =>6
 
이 외의 경우는
if a>b => 90-a*10-b
if a<b => 90-b*10-a
 
이런식으로 tier을 부여합니다.
 
ex) 5 6
90 - 6 * 10 - 5 = 25
 
ex) 2 3
90 - 3* 10 - 2 = 58
 
5 6 이 2 3 보다 tier 숫자가 낮다 => 5 6 이 2 3 을 이긴다!!!