Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求数据!!求数据!!求解释, 为什么wa!!!

Posted by sicojuy at 2011-04-24 14:07:35 on Problem 1961
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator