hdu 1358 Period
来源:互联网 发布:绘画软件价格 编辑:程序博客网 时间:2024/06/05 06:57
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1358
题目大意:解释一下输出数据,
第一组:
2 2 表示的是第一个字母到第二字母,a出现了两次。
3 3 表示的是第一个字母到第三个字母,a出现了3次。
第二组:
2 2表示的是第一个字母到第二个字母,a出现了两次。
6 2表示的是第一个字母到第六个字母,aab出现了两次。
9 3表示的是第一个字母到第九个字母,aab出现了三次。
12 4表示的是第一个字母到第十二个字母,aab出现了四次。
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 5 using namespace std; 6 7 int next[1000010]; 8 char str[1000010]; 9 10 void get_next()11 {12 int i=0,j=-1;13 next[0]=-1;14 int lens=strlen(str);15 while (i<lens)16 {17 if (j==-1||str[i]==str[j])18 {19 i++;20 j++;21 next[i]=j;22 if (i>=2&&j>=1)23 {24 if (i%(i-next[i])==0)25 {26 int k=i/(i-next[i]);27 printf ("%d %d\n",i,k);28 }29 }30 }31 else32 j=next[j];33 }34 }35 int main ()36 {37 int n,flag=1;38 while (scanf("%d",&n),n)39 {40 getchar();41 scanf("%s",str);42 printf ("Test case #%d\n",flag++);43 get_next();44 printf ("\n");45 //lens=strlen(str);46 }47 return 0;48 }
0 0
- HDU 1358 Period (KMP)
- HDU 1358 Period
- hdu 1358 Period
- hdu 1358 Period
- hdu 1358 Period
- HDU 1358 Period KMP
- hdu 1358 Period
- hdu 1358 Period KMP
- hdu 1358 Period(KMP)
- HDU 1358 Period KMP
- hdu 1358 Period
- hdu 1358 Period
- 【HDU】1358 Period KMP
- HDU - 1358 Period
- HDU 1358 Period (KMP)
- HDU 1358 Period
- hdu 1358 Period
- HDU 1358 Period
- hdu 1237 简单计算器
- hdu 1061 Rightmost Digit
- hdu 2141 Can you find it?(二分查找)
- hdu 2899 Strange fuction (二分)
- hdu 2817 A sequence of numbers(快速幂取余)
- hdu 1358 Period
- 冒泡排序
- hdu 3746 Cyclic Nacklace
- hdu 2199 Can you solve this equation?
- 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication
- hdu 1686 Oulipo (kmp)
- hdu 1711 Number Sequence
- 最受欢迎的5个Android ORM框架
- hdu 1399 Starship Hakodate-maru (暴力搜索)