传送门:http://www.ifrog.cc/acm/problem/1054
思路:
首先知道这样一个性质,删除一个字符之后的字符串的循环节长度一定是nn的约数。所有我们就枚举删除哪一个字符,然后对每一个约数判断是否可以循环节为它。复杂度O(nlogn)
代码:
#include
#include
#include
#include
using namespace std;
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rrep(i,k,n) for(int i=k;i>=n;i--)
#define pl(x) cout << #x << "= " << x << endl;
template void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
const int N=1e5+10;
string s;
int main(){
int T;
read(T);
while(T--){
int n;
read(n);
// if(n==1) return 0*puts(0);
cin>>s;
int mx=0;
rep(i, 0, n-1){
string ss = s.substr(0, i);
ss = ss+s.substr(i+1, n-i);
// cout<<"ss="<
描述:
Time Limit:4s Memory Limit:64MByte
Submissions:151Solved:54
A string cut cc means the string can be divided into cc same substring. Such as string: abababababab.Because it can be divied into abab + abab + abab, the string cut of it is 33.
Give you a string strstr.you need to delete one char of it ,and after your operation the string cut of it will be biggest.Print the biggest string cut.