日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Power Strings

發布時間:2025/3/15 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Power Strings 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目連接

1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 6 inline int read() 7 { 8 int x=0,f=1;char ch=getchar(); 9 while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 10 while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 11 return x*f; 12 } 13 14 15 /********************************************************************/ 16 17 const int maxn = 2e7+7; 18 char s[maxn]; 19 int Next[maxn]; 20 21 22 int main(){ 23 while(~scanf("%s", s+1)){ 24 if(s[1] == '.') break; 25 int len = strlen(s+1); 26 int k = 0; 27 Next[1] = 0; 28 for(int i = 2;i <= len;i++){ 29 while(k > 0 && s[k+1] != s[i]){ 30 k = Next[k]; 31 } 32 if(s[k+1] == s[i]){ 33 k++; 34 } 35 Next[i] = k; 36 } 37 38 if(len%(len-Next[len])){ 39 printf("1\n"); 40 } 41 else printf("%d\n", len/(len-Next[len])); 42 43 } 44 return 0; 45 }

?

轉載于:https://www.cnblogs.com/ouyang_wsgwz/p/9735663.html

總結

以上是生活随笔為你收集整理的Power Strings的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。