You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
739 B
C++

#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
char str[1050];
int main()
{
int T;
scanf("%d", &T);
unordered_set<pair<ull, ull>> S;
while (T--)
{
S.clear();
scanf("%s", str);
int n = strlen(str);
for (int i = 0; i < n; i++)
{
ull ans1 = 1, ans2 = 1;
for (int j = i; j < n; j++)
{
ans1 = ans1 * 131 + str[j];
ans2 = ans2 * 267 + str[j];
S.insert(make_pair(ans1, ans2));
}
}
cout << S.size() << endl;
}
return 0;
}