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 OSJake at 2009-06-16 21:12:18 on Problem 2406
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;
string a;
int lena;
char str[100001];
bool check(int len)
{
     int i,j;
     if(lena%len!=0)return false;
     else
     {
                   for(int k=0;k<10000;k++)
                   {
                           int base=rand()%(lena/len);
                           for(int l=0,i=base*len;i<(base+1)*len;i++,l++)
                           if(str[l]!=a[i])return false;
                           }
     }
     return true;
}
     
                   
     
int main()
{
    
    while(cin>>a)
    {
                         if(a==".")break;
                         lena=a.length();
                         int i;
                         int len=0;
                         for(i=1;i<=lena;i++)
                         {
                                             str[i-1]=a[i-1];
                                             len++;
                                             if(check(i))break;
                          }
                        printf("%d\n",lena/len);
                          }
                          return 0;
}
老wa,算法错了还是........

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