国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Power Strings

2019-11-10 18:34:53
字體:
來源:轉載
供稿:網友

PRoblem Description Given two strings a and b we define a*b to be their concatenation. For example, if a = “abc” and b = “def” then a*b = “abcdef”. If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = “” (the empty string) and a^(n+1) = a*(a^n). Input Each test case is a line of input representing s, a string of printable characters. The length of s will be at least 1 and will not exceed 1 million characters. A line containing a period follows the last test case.

Output For each s you should print the largest n such that s = a^n for some string a.

Example Input

abcdaaaaababab.

Example Output

143

Hint This problem has huge input, use scanf instead of cin to avoid time limit exceed.

Author

#include<stdio.h>#include <string.h>#define N 1010000char p[N];int main(){ while(gets(p)) { int b=strlen(p); if(b==1&&p[0]=='.')break; int max=1; int c; for(int a=1; a<=b/2;a++) { if(b%a!=0)continue; int d; for(c=0, d=0; c<b; c++, d++) { if(d==a)d=0; if(p[d]!=p[c])break; } if(c==b) { max=b/a; break; } } printf("%d/n", max); } return 0;}
上一篇:TimeUtil

下一篇:循環隊列

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 磴口县| 阿拉善右旗| 云阳县| 平定县| 常熟市| 乌恰县| 兰州市| 嘉祥县| 班戈县| 二连浩特市| 囊谦县| 延长县| 东乌珠穆沁旗| 长寿区| 金川县| 平度市| 绵阳市| 龙海市| 肃南| 泗水县| 宁陵县| 迭部县| 长丰县| 莱州市| 莎车县| 贵定县| 威宁| 凉城县| 宽城| 尚义县| 叙永县| 鄄城县| 法库县| 平谷区| 崇信县| 辽阳市| 连江县| 内黄县| 永兴县| 双峰县| 淳安县|