본문 바로가기
python-algorithm

백준 9713 Sum of Odd Sequence

by 무적김두칠 2022. 12. 6.

https://www.acmicpc.net/problem/9713

 

9713번: Sum of Odd Sequence

First line of the input contains T, the number of test cases. Each test case contains a single integer N. N is between 1 and 100.

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
10
def sol(n):
    answer = (n//2+1)**2
 
    return answer
 
if __name__ == '__main__':
    t = int(input())
    for _ in range(t):
        n = int(input())
        print(sol(n))
cs

홀수의 합 구하는 공식:
n^2

반응형

'python-algorithm' 카테고리의 다른 글

백준 6976 Divisibility by 11  (0) 2022.12.07
백준 5940 Math Practice  (0) 2022.12.07
백준 26041 비슷한 전화번호 표시  (0) 2022.12.06
백준 6500 랜덤 숫자 만들기  (0) 2022.12.06
백준 7120 String  (0) 2022.12.05

댓글