Cod sursa(job #3161510)
Utilizator | Data | 27 octombrie 2023 12:57:25 | |
---|---|---|---|
Problema | Prefix | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.59 kb |
#include <bits/stdc++.h>
using namespace std;
int n,nw,rsp,leng;
string s;
int main()
{
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>s;
int sz=s.size();
rsp=0;
leng=1;
nw=0;
for (int j=1;j<sz;j++)
{
if (s[j]==s[j-leng])
{
nw++;
}
else
{
nw=0;
leng=i;
}
if (nw==leng)
{
nw=0;
rsp=i;
}
}
}
g<<rsp<<'\n';
}