백준 30445번: 행복 점수 #Python

ColorlessDia·2025년 1월 28일

algorithm/baekjoon

목록 보기
436/836
line = input()

PH, PG = 0, 0

for char in line:

    if char == 'A':
        PH += 1
        PG += 1
    elif char in 'HPY':
        PH += 1
    elif char in 'SD':
        PG += 1

H = 5000

if not (PH == PG == 0):
    temp = (PH * 100000) // (PH + PG)

    if 5 <= temp % 10:
        temp += 10
    
    H = temp // 10

print(f'{(H * 0.01):.2f}')

0개의 댓글