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

测试数据

Posted by jackch at 2006-09-08 18:15:45 on Problem 2406
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    char str[1000001];
    while(cin>>str&&strcmp(str,".")!=0)
    {
         int count=0;
         char*p=str;
         int len=strlen(str);
         for(int i=2;i<=1000;i++)
         {
              while(len%i==0)
              {
                  char*q[i]; int l=0,k=0;
                  for(int j=0;j<i;j++)
                  q[j]=&str[j*(len/i)];
                  while(l==0&&k<len/i)
                  {
                       for(int j=0;j<i-1;j++)
                       {if(*q[j]++!=*q[j+1])
                         {l=1;break;}
                       }
                       if(l==1)break;
                       q[i-1]++;
                       k++;
                  }
                  if(k==len/i&&l==0)
                   {count+=i;
                    memmove(str,str,len/i);
                    len=len/i;
                   }
                   else break;
                  
              }
         }
         
         if(count==0)cout<<1<<endl;
         else cout<<count<<endl;
    }
    getchar();
    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