https://www.acmicpc.net/problem/11478
11478번: 서로 다른 부분 문자열의 개수
첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000 이하이다.
www.acmicpc.net
# 11478 - Python 3
import sys
input = sys.stdin.readline
s = input().strip() # 개행문자 제거 위해 strip() 함수 사용
arr = []
for i in range(len(s)):
for j in range(i, len(s)):
temp = s[i : j+1] # 가능한 경우들
arr.append(temp)
arr = set(arr) # 중복 제거
print(len(arr))'코딩' 카테고리의 다른 글
| [Python] 백준 #10870. 피보나치 수 5 (0) | 2023.03.20 |
|---|---|
| [Python] 백준 #10872. 팩토리얼 (0) | 2023.03.18 |
| [Python] 백준 #1269. 대칭 차집합 (0) | 2023.03.18 |
| [Python] 백준 #1764. 듣보잡 (0) | 2023.03.18 |
| [Python] 백준 #10816. 숫자 카드 2 (0) | 2023.03.18 |