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

为什么tle

Posted by Headacher at 2008-10-17 23:31:40 on Problem 2406
#include<iostream>
#include<cstring>
using namespace std;
char s[1000000];
int main()
{   while(scanf("%s",s))
    {   int len=strlen(s);
        if(s[0]=='.')
           break;
        int i,j;
        for(i=1;;i++)
        {   bool can=1;
            for(j=0;j<i;j++)
            {   
                int k;
                for(k=j;;k=k+i)
                {   if(k+i>=len)
                    {   break;
                    }
                    if(s[k]!=s[k+i])
                    {   can=0;//i不能用,break 
                        break;
                    }
                    
                }
                if(can==0)//i不能用,找i+1 
                       break;
                
            }
            if(can==1)//i可以用输出len/i 
              break;
            
        }
        printf("%d\n",len/i);
    }
    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