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

看到题目也没多想总之暴力过了……204MS

Posted by yyii1111 at 2012-01-10 18:38:04 on Problem 2406
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

char input[10000000];

bool check(int x,int l)
{
    for(int i=x;i<l;i+=x)
    {
        for(int j=0;j<x;j++)
            if(input[i+j] != input[j])
                return false;
    }
    return true;
}

void solve()
{
    int l = strlen(input);
    for(int i=1;i<=l;i++)
        if(l%i == 0)
        {
            if(check(i,l))
            {
                printf("%d\n",l/i);
                return;
            }
        }
}

int main()
{
    while(scanf("%s",input),input[1])
        solve();
    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