#include <iostream>
using namespace std;
const int MAXN = 1000;
bool judge(int a[], int n) {
for (int i = 2; i <= n; i++) {
if (a[1] != a[i])
return false;
}
return true;
}
int main() {
int n;
int candy[MAXN];
int round = 0;
while (cin >> n && n) {
for (int i = 1; i <= n; i++) {
cin >> candy[i];
}
round = 0;
while (!judge(candy, n)) {
round++;
candy[0] = candy[n];
for (int i = n; i >= 1; i--) {
if (candy[i] & 1)
candy[i] = candy[i]/2 + 1 + candy[i-1]/2;
else
candy[i] = candy[i]/2 + candy[i-1]/2;
if (candy[i] & 1)
candy[i]++;
}
}
cout << round << " " << candy[1] << endl;
}
return 0;
}
HDU1034-Candy Sharing Game
最新推荐文章于 2019-07-18 16:44:38 发布