Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
随机测试可以吗?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator