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

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Power Strings

2019-11-10 17:59:13
字體:
供稿:網(wǎng)友

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;}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 淳安县| 五家渠市| 泰顺县| 连江县| 赞皇县| 鸡西市| 霍林郭勒市| 静宁县| 乐山市| 萨迦县| 延边| 体育| 炉霍县| 九龙城区| 娱乐| 当雄县| 新兴县| 泌阳县| 临安市| 怀化市| 克什克腾旗| 碌曲县| 蒲江县| 吴江市| 江陵县| 南漳县| 南召县| 视频| 马龙县| 瑞丽市| 甘德县| 美姑县| 泗洪县| 昂仁县| 浦城县| 瓮安县| 循化| 馆陶县| 望城县| 香格里拉县| 秦皇岛市|