10分求解
查看原帖
10分求解
1770769
wym2015楼主2025/7/1 19:33

10分代码:

#include<bits/stdc++.h>
using namespace std;
int n,m,k=4;
char a[110],b[1010],c[1010];
bool njj(){
	for(int i=1;i<=k;i++){
		if(b[i]!=c[i]) return false;
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			b[j]=a[j];
		}
		for(int j=k;j<=k*2;j++){
			if(k>n/2){
				cout<<k;
				return 0;
			}
			c[j]=a[j];
		}
		if(njj()==1){
		cout<<k;
		}
		else k++;
		
	}
	
	return 0;
}
求大佬解法
2025/7/1 19:33
加载中...