Pagini recente » Cod sursa (job #2867613) | Cod sursa (job #780312) | Cod sursa (job #625248) | Cod sursa (job #57527) | Cod sursa (job #3235186)
/// MihneaTheMogger was here
/// #MLC
#pragma GCC optimize("O4,unroll-loops,fast-math")
#define debug(x) #x << " = " << x << '\n'
#include <bits/stdc++.h>
#define EVAL_USE_FI 0
#define EVAL_USE_FO 0
#define EVAL_FI_NAME "prefix.in"
#define EVAL_FO_NAME "prefix.out"
#define EVAL_USE_FASTIO 1
/// Local
#define LOCAL_USE_FI 0
#define LOCAL_USE_FO 0
#define LOCAL_FI_NAME "main.in"
#define LOCAL_FO_NAME "main.out"
#define LOCAL_USE_FASTIO 1
/// General
#define GENERAL_MULTIPLE_TESTCASES 1
#define GENERAL_USE_INT128_IO 0
#define GENERAL_USE_INT_AS_LONG_LONG 1
using namespace std;
#if GENERAL_USE_INT128_IO == 1
istream& operator>> (istream& in, __int128 &x)
{
char ch;
int mul = 1;
while (!isdigit (ch = in.get()) && ch != '-');
if (ch == '-')
{
mul = -1;
ch = in.get();
}
while (isdigit (ch))
{
x = x * 10 + ch - '0';
ch = in.get();
}
return in;
}
ostream& operator<< (ostream& out, __int128 x)
{
string s;
do
{
s += (x % 10 + '0');
x /= 10;
}
while (x);
for (int i = s.size() - 1; i >= 0; i --)
out << s[i];
return out;
}
#endif
void preinit();
void solve();
ifstream fin;
ofstream fout;
int32_t main()
{
#ifndef LOCAL
#if EVAL_USE_FI == 1
fin.open (EVAL_FI_NAME);
#define cin fin
#endif
#if EVAL_USE_FO == 1
fout.open (EVAL_FO_NAME);
#define cout fout
#endif
#if EVAL_USE_FASTIO == 1
ios_base::sync_with_stdio (false);
cin.tie (NULL);
cout.tie (NULL);
#endif
#else
#if LOCAL_USE_FI == 1
fin.open (LOCAL_FI_NAME);
#define cin fin
#endif
#if LOCAL_USE_FO == 1
fout.open (LOCAL_FO_NAME);
#define cout fout
#endif
#if LOCAL_USE_FASTIO == 1
ios_base::sync_with_stdio (false);
cin.tie (NULL);
cout.tie (NULL);
#endif
#endif
preinit();
#if GENERAL_MULTIPLE_TESTCASES == 1
/// WARNING: Multiple Testcases Enabled
int t; cin >> t;
for (; t; t --) solve();
#else
solve();
#endif
return 0;
}
#if GENERAL_USE_INT_AS_LONG_LONG == 1
#define int int64_t
#endif
void preinit()
{
}
void solve()
{
string s; cin >> s;
string p = s;
while (!p.empty())
{
bool ok = 0;
for (int sz = p.size() / 2; sz >= 1; sz --)
{
if (p.size() % sz == 0)
{
string b = "", c = p.substr(0, sz);
while (b.size() < p.size())
{
b += c;
}
if (b == p)
{
ok = 1;
}
}
}
if (ok)
{
cout << p.size() << '\n';
return;
}
p.pop_back();
}
cout << 0 << '\n';
}
/**
*/