성적 평균

발자·2023년 5월 11일
0

Softeer

목록 보기
14/17

문제

# 학생 수 N, 구간 수 K
N, K = map(int, input().split())

# 점수
point = list(map(int, input().split()))

for i in range(K):
    # x~y 구간
    x, y = map(int, input().split())
    # 평균
    n = sum(point[x-1:y]) / (y-(x-1))
    # 소수점 2자리까지만 출력
    print("{:.2f}".format(n))

🧩 소수점 이하 n번째까지 출력

0개의 댓글