본문 바로가기

CodingTest/SW Expert Academy

[ SW Expert Academy ] 1986. 지그재그 숫자

1차 제출. [ 10 / 10 ] PASS

엥 .. 얘는 D2가 아니라 D1수준인데..

T = int(input())
for tc in range(1, T+1):
    n = int(input())
    result = 0
    for i in range(1, n+1):
        if i % 2 != 0:
            result += i
        else:
            result -= i
    print("#{} {}".format(tc,result))