#ํ์ X ๊ณผ๋ชฉ ํ์ / ํ์ ์ ์ดํฉ
object, score, rating = [],[],[]
rating_list = {"A+":4.5,"A0":4.0,"B+":3.5,"B0":3.0,"C+":2.5,"C0":2.0,"D+":1.5,"D0":1.0,"F":0.0}
score_sum = 0
scra = 0 # ํ์ X ๊ณผ๋ชฉ ํ์
cnt = 0
for _ in range (20) :
object, score, rating = input().split()
score = float(score)
if rating != "P":
scra += score*rating_list.get(rating)
score_sum += score
print(format(scra/score_sum,".6f"))
๐ฌ score ๊ฐ์ float ๋ก ํ๋ณํ ํด์ฃผ๊ธฐ
๐ฌ rating = ๋ฑ๊ธ์ด P ์ผ ๊ฒฝ์ฐ์๋ ๊ณ์ฐํ์ง ์๋ ๋ค๋ ์กฐ๊ฑด ์ถ๊ฐํด์ฃผ๊ธฐ
๐ฌ ๋์ ๋๋ฆฌ๋ฅผ ํตํด์ ํค : ๊ฐ์ ๊ฐ์ ธ์ค๊ธฐ
<< ๐คฎ ๋งํ ์ด์ & ํด๊ฒฐ >>
object, score, rating = [],[],[]
rating_list = {"A+":4.5,"A0":4.0,"B+":3.5,"B0":3.0,"C+":2.5,"C0":2.0,"D+":1.5,"D0":1.0,"F":0.0}
score_sum = 0
scra = [] # ํ์ X ๊ณผ๋ชฉ ํ์
cnt = 0
for _ in range (20) :
object, score, rating = input().split()
if rating == "P":
cnt += 1
for i in range (20-cnt):
for _ in rating :
scra = score[i]*rating_list.get(rating)
score_sum += score
print(scra/score_sum)
์ด๊ฑด ์ ๋ค ๋งํ ๋ด ์ฝ๋ ... (์คํจํ ์ฝ๋์)
์ด๋ฐ ๊ตฌํ์ ์ด๋ ๊ฒ ํ๊ณ ๋ค๋ฅธ ๊ฑธ ์ฐพ์๋ณด๋ฉด์ ์์ ํด์คฌ๋ค.
์ค๋๋ง์ ๋์ ๋๋ฆฌ๋ฅผ ์ฌ์ฉํด๋ดค๋ค!!
๐ฌ ๋์ ๋๋ฆฌ .get(ํค) => ํค์ ๋์ํ๋ ๊ฐ ๋ฐํ
๐ฌ format(result, ".6f")๋ 0.3141592 ๊ฐ์ ์์์ ์ดํ 6์๋ฆฌ๊น์ง ํฌ๋งทํจ