티스토리 뷰

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 을 이긴다!!!

'Pascal > BAEKJOON' 카테고리의 다른 글

pascal 24765번 Mia (백준)  (0) 2025.09.13
pascal 15079번 Arggggggh! (백준)  (0) 2025.08.31
pascal 31312번 Water Journal (백준)  (0) 2025.08.31
pascal 31097번 Astrology (백준)  (0) 2025.08.31
pascal 6919번 Fraction Action (백준)  (0) 2025.08.29
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/01   »
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 31
글 보관함