样例全过为啥0分?
查看原帖
样例全过为啥0分?
235901
Always_Remember_It楼主2023/11/2 22:25
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=310;
char cnt[N],tot[N];
signed main(){
	int T;cin>>T;
	while(T--){
		string s;cin>>s;
		int l=s.size();
		s=' '+s;
		int sum=0;
		for(int i=1;i<=l-2;i++){
			int num=0;
			memset(cnt,0,sizeof(cnt));
			for(int j=1;j<=i;j++){
				++cnt[s[j]];
			}
			for(char w='a';w<='z';w++){
				if(cnt[w]%2==1) ++num;
			}
			for(int j=i+1;j<=l-1;j++){
				for(int k=0;(k+1)*j<=l-1;k++){
					int c=0;
					memset(tot,0,sizeof(tot));
					for(int p=(k+1)*j+1;p<=l;p++){
						++tot[s[p]];
					}
					for(char w='a';w<='z';w++){
						if(tot[w]%2==1) ++c;
					}
					if(num>c) continue;
					bool f=1;
					for(int p=1;p<=j;p++){
						if(s[p]!=s[k*j+p]){
							f=0;
							break;
						}
					}
					if(!f) break;
					++sum;
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}
2023/11/2 22:25
加载中...