60求条
查看原帖
60求条
1368992
I_AM_ACer楼主2024/9/13 22:16

这道题不明不白地拿了60分,蒟蒻不知道该怎么改,求大佬帮忙调调

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100005;
int a[N];
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
		{
			f=-1;	
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0',ch=getchar();
	}
	return x*f;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int cnt=1;
	string n;
	while(cin>>n)
	{
		for(int i=0;i<n.size();i++)
		{
			a[cnt]=n[i]-'0';
			cnt++;
		}
	}
	cout<<sqrt(cnt-1)<<" ";
	int sum=0;
	for(int i=1;i<=cnt;i++)
	{
		if(a[i]!=a[i-1])
		{
			cout<<sum<<" ";
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	return 0;
}

提交记录

2024/9/13 22:16
加载中...