이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<string.h>
#define mx 1000005
using namespace std;
char arr[mx];
int prefix[mx];
void prefix_array(string s)
{
int l = s.length();
for(int i=1; i<l; i++)
{
int j = prefix[i-1];
while(j>0 && s[i]!=s[j])
{
j = prefix[j-1];
}
if(s[i]==s[j])
{
j++;
}
prefix[i] = j;
}
}
int main()
{
while(scanf("%s",arr))
{
int l= strlen(arr);
if(arr[0]=='.')
break;
prefix_array(arr);
int d = l - prefix[l-1];
if(l%d==0)
{
cout << l/d << endl;
}
else
{
cout << 1 << endl;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |