[SW Expert Academy] 14178. 1차원 정원

rhkr·2022년 5월 28일
0

SWEA

목록 보기
1/1

주의!! 출력에서 #1 ~ 이렇게 샵(#) 이 나오는데, 이 샵(#) 도 print해야한다!!

알고리즘 = 전체 길이가 N 이고 분무기 영역이 2*D+1 이므로
ceil(N/D) 하면 전체 물을 줄 수 있는 최소의 분무기 수 계산 가능.

import math

if __name__ == '__main__':
    testcase = int(input())
    i = 1
    while (testcase):
        testcase -= 1
        N, D = map(int, input().split())
        print(f"#{i} " + str(math.ceil(N/(2 * D + 1))))
        i = i + 1

0개의 댓글