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 Rossi at 2009-03-24 17:01:55 on Problem 2406
帮我测测数据好吧,我想知道哪组不行。
一直WA,郁闷~~
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int power(char *s,int len)
{
  register int divide,test,flag=1;
  char tmp1[500000],tmp2[500000];
  for(divide=1;divide<len;divide++)
  {
    if(len%divide==0)
    {
      strncpy(tmp1,s,divide);
      tmp1[divide]='\0';
      for(test=divide;test<len;test+=divide)
      {
        strncpy(tmp2,s+test,divide);
        tmp2[divide]='\0';
        if(strcmp(tmp1,tmp2)!=0)
        {
          flag=0;
          break;
        }
      }
      if(flag) return len/divide;
      else flag=1;
    }
  }
  return 1;
}
int main(void)
{
  char str[1000001];
  while(scanf("%s",str))
  {
    if(strcmp(str,".")==0) break;
    printf("%d\n",power(str,strlen(str)));
  }
  system("PAUSE");
  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