티스토리 뷰
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
t = int(input())
for case in range(t):
n = int(input())
answer = [[1]]
for i in range(1, n):
temp = []
for j in range(i+1):
if j == 0 or j == i:
temp.append(1)
else:
temp.append(answer[i-1][j-1] + answer[i-1][j])
answer.append(temp)
print("#%d" % (case+1))
for line in answer:
print(' '.join(map(str, line)))
설명
삼각형 한줄한줄에서 양 끝은 항상 1
양 끝이 아니면 (위왼쪽+위)
'ALGORITHM > SW Expert' 카테고리의 다른 글
| [Python]SW Expert - 초심자의 회문 검사(D2) (0) | 2020.03.07 |
|---|---|
| [Python]SW Expert - 지그재그 숫자(D2) (0) | 2020.03.07 |
| [Python]SW Expert - 패턴 마디의 길이(D2) (1) | 2020.03.06 |
| [Python]SW Expert - 간단한 369게임(D2) (0) | 2020.03.06 |
| [Python]SW Expert - 파리 퇴치(D2) (0) | 2020.03.06 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- hash
- 해시
- C++
- 스택
- 백준
- 문자열처리
- 2019 Kakao Blind Recruitment
- 문자열
- 정렬
- SW Expert
- 2020 KAKAO BLIND RECRUITMENT
- 코딩테스트
- Python
- 완전탐색
- dictionary
- 파이썬
- BOJ
- 프로그래머스
- 구현
- combination
- Permutation
- 우선순위큐
- 괄호
- 순열
- SWExpert
- 재귀
- 힙
- left join
- 딕셔너리
- programmers
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
글 보관함