zst0915 @ 2024-03-08 23:03:05
#include<bits/stdc++.h>
using namespace std;
int n[204];
int main()
{
int a,m[10000],b=1,c=1;
while(cin>>a)
{
m[b]=a;
b++;
}
for(int i=1;i<=b;i++)
{
if(m[i]==0||m[i]==1)
n[c]++;
if((m[i]==0&&m[i+1]==1)||(m[i]==1&&m[i+1]==0))
c++;
}
cout<<sqrt(b)<<" ";
for(int i=1;i<=c;i++)
{cout<<n[i]<<" ";}
return 0;
}
by ggpw_XNW @ 2024-03-09 08:13:29
@zst0915
#include<iostream>
#include<cmath>
using namespace std;
int a[40005] , n , p = 0 , k = 0;
char a1;
int main()
{
while(cin >> a1)
{
if(a1-'0'!=k){p++;k=!k;}
a[p]++;
n++;
}
cout << sqrt(n) << " ";
for(int i=0;i<=p;i++)
{
cout << a[i] << " ";
}
return 0;
}
by zst0915 @ 2024-03-09 08:50:18
@User1025109 我看懂了,谢谢~!!