标签:efi input ble font plm single field sea tput
Time Limit: 3000MS | Memory Limit: 30000K | |
Description
Input
Output
Sample Input
3 aaa 12 aabaabaabaab 0
Sample Output
Test case #1 2 2 3 3 Test case #2 2 2 6 2 9 3 12 4
Source
#include<cstdio> #include<cstring> #include<iostream> using namespace std; int n,t; char s[1000001]; int f[1000010]; void getnext() { for(int i=1;i<n;i++) { int j=f[i]; while(j&&s[i]!=s[j]) j=f[j]; f[i+1]= s[i]==s[j] ? j+1:0; if(i>=1&&f[i+1]) { int a=i+1-f[i+1]; if((i+1)%a==0) printf("%d %d\n",i+1,(i+1)/a); } } } int main() { while(scanf("%d",&n)!=EOF) { t++; if(!n) return 0; scanf("%s",s); memset(f,0,sizeof(f)); printf("Test case #%d\n",t); getnext(); printf("\n"); } }
标签:efi input ble font plm single field sea tput
原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/6485880.html