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 |
看到题目也没多想总之暴力过了……204MS#include <iostream> #include <cstring> #include <cstdio> using namespace std; char input[10000000]; bool check(int x,int l) { for(int i=x;i<l;i+=x) { for(int j=0;j<x;j++) if(input[i+j] != input[j]) return false; } return true; } void solve() { int l = strlen(input); for(int i=1;i<=l;i++) if(l%i == 0) { if(check(i,l)) { printf("%d\n",l/i); return; } } } int main() { while(scanf("%s",input),input[1]) solve(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator