sasassas
2024-06-27 20:25:58
发布于:广东
7阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,s[110];
bool f()
{
for (int i = 1;i < n;i++)
if (s[i] != s[i - 1])
return false;
return true;
}
int main()
{
cin>>n;
for (int i = 0;i < n;i++)
cin >> s[i];
if (f())
cout << 0 << endl;
else
{
int t = 0;
while (!f())
{
int w = s[0];
for (int i = 0;i < n - 1;i++)
{
s[i] = s[i]+s[i + 1] / 2;
s[i + 1] = s[i + 1] / 2;
}
s[n - 1] += w / 2;
s[0] -= w / 2;
for (int i = 0;i < n;i++)
if (s[i] % 2 == 1)
{
t++;
s[i] += 1;
}
}
cout << t << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个