Skip to content

Commit 7c7718e

Browse files
committed
[BOJ] #25206. 너의 평점은 / 실버5 / 25분 / 성공
1 parent a3ceb5b commit 7c7718e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
# 1. 과목 평점 테이블 (딕셔너리 사용)
5+
rating = {
6+
"A+": 4.5, "A0": 4.0,
7+
"B+": 3.5, "B0": 3.0,
8+
"C+": 2.5, "C0": 2.0,
9+
"D+": 1.5, "D0": 1.0,
10+
"F": 0.0
11+
}
12+
13+
# 2. 변수 초기화
14+
total_score = 0 # 총 평점 (학점 * 과목 평점의 합)
15+
total_credit = 0 # 총 학점
16+
17+
# 3. 과목별 입력 및 평점 계산
18+
for _ in range(20):
19+
subject, credit, grade = input().split()
20+
credit = float(credit) # 학점은 소수점으로 변환
21+
22+
if grade != 'P': # P 등급 과목 제외
23+
total_score += credit * rating[grade]
24+
total_credit += credit
25+
26+
# 4. 전공 평점 계산 및 출력
27+
GPA = total_score / total_credit
28+
print("{:.6f}".format(GPA)) # 소수점 6자리 출력

0 commit comments

Comments
 (0)