| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求数据!!求数据!!求解释, 为什么wa!!!#include <cstdio>
#include <cstring>
#define N 1000005
char str[N];
int main()
{
int len;
int period, count;
int test = 0;
int i, j;
while(scanf("%d", &len), len)
{
scanf("%s", str + 1);
printf("Test case #%d\n", ++test);
for(count = period = 1, j = 1, i = 2; i <= len; ++j, ++i)
{
if(str[i] != str[j])
{
period = period * count + j;
count = 1;
j = 0;
}
else if(j == period)
{
++count;
printf("%d %d\n", i, count);
j = 0;
}
}
printf("\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator