728x90
문제: https://www.acmicpc.net/problem/11478
string의 substr 함수를 사용하여 풀었다.
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
string S;
unordered_set<string> Answer;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> S;
for (int i = 0; i < S.size(); ++i)
for (int j = 1; i + j <= S.size(); ++j)
Answer.insert(S.substr(i, j));
cout << Answer.size() << "\n";
}
728x90
'📕알고리즘 문제 > 📝Baekjoon' 카테고리의 다른 글
| [백준] 실버4 : (2217) 로프 (0) | 2024.11.08 |
|---|---|
| [백준] 골드5 : (2170) 선 긋기 (0) | 2024.11.07 |
| [백준] 실버1 : (11659) 구간 합 구하기 5 (0) | 2024.10.03 |
| [백준] 실버1 : (1932) 정수 삼각형 (0) | 2024.04.18 |
| [백준] 실버2 : (2512) 예산 (0) | 2024.04.16 |