https://www.acmicpc.net/problem/2480
1. 메인 아이디어
- 조건 그대로 조건문 로직을 만든다.
- dictionary를 활용하여 max_number, max_count로도 문제풀이가 가능하다
- 단순 구현법
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
if a == b == c:
print(10000 + a * 1000)
elif (a == b != c) or (b == c != a):
print(1000 + b * 100)
elif a == c != b:
print(1000 + a * 100)
else:
print(max(a,b,c) * 100)
- 딕셔너리를 이용한 방법
import sys
input = sys.stdin.readline
a, b, c = map(int, input().split())
# 주사위 숫자의 개수를 센다
count = {a: 0, b: 0, c: 0}
count[a] += 1
count[b] += 1
count[c] += 1
# 가장 많이 나온 숫자와 그 개수 찾기
max_num = max(count, key=lambda x: count[x])
max_count = count[max_num]
if max_count == 3:
prize = 10000 + max_num * 1000
elif max_count == 2:
prize = 1000 + max_num * 100
else:
prize = max(a, b, c) * 100
print(prize)
'Coding Test > Baek Joon.' 카테고리의 다른 글
2525 - 오븐시계 (0) | 2024.08.31 |
---|---|
2870 - 수학숙제 (0) | 2024.08.25 |
2910 - 빈도 정렬 (0) | 2024.08.24 |
2828 - 사과 담기 게임 (2) | 2024.08.23 |
1992 - 쿼드트리 (0) | 2024.08.22 |