본문 바로가기
python-algorithm

백준 5341 Pyramids

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

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

 

5341번: Pyramids

The input will be a sequence of integers, one per line. The end of input will be signaled by the integer 0, and does not represent the base of a pyramid. All integers, other than the last (zero), are positive.

www.acmicpc.net

 

1
2
3
4
5
6
7
8
9
def sol(n):
    return int(n*(n+1)/2)
 
if __name__ == '__main__':
    while 1:
        n = int(input())
        if n == 0:
            break
        print(sol(n))
cs
반응형

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

백준 10189 Hook  (0) 2022.12.19
백준 6840 Who is in the middle?  (0) 2022.12.17
백준 26489 Gum Gum for Jay Jay  (0) 2022.12.17
백준 26057 Большой удой  (1) 2022.12.13
백준 11008 복붙의 달인  (0) 2022.12.13

댓글