题目有坑

如果初始小朋友的糖果为奇数的话,小朋友给同学n/2个糖果,自己留n/2+1个糖果

#include<iostream>
#include<vector>
#include<algorithm>
#define MAX 10000
using namespace std;
int a[MAX + 1];
//判断游戏是否结束
bool is_end(vector<int>v) {
	if (v.size() == 1)return true;
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[0])return false;
	}
	return true;
}
//进行游戏
void game(vector<int>&v) {

	
	vector<int>v2;
	if (v[0] % 2 == 0) {
		v2.push_back(v[0] / 2 + v[v.size() - 1] / 2);
	}
	else {
		v2.push_back(v[0] / 2 + v[v.size() - 1] / 2 + 1);
	}
	
	for (int i = 1; i < v.size(); i++) {
		int temp;
		if (v[i] % 2 == 0) {
			temp = v[i - 1] / 2 + v[i] / 2;
		}
		else {
			temp = v[i - 1] / 2 + v[i] / 2 + 1;
		}
		v2.push_back(temp);
	}
	//将v2复制到v
	for (int i = 0; i < v.size(); i++) {
		v[i] = v2[i];
	}
	//老师将糖果补齐
	for (int i = 0; i < v.size(); i++) {
		if (v[i] % 2 == 1) {
			v[i]++;
		}
	}
	
}
int main() {
	int N;
	vector<int>v;
	while (cin >> N) {
		v.clear();
		if (N == 0)return 0;
		for (int i = 0; i < N; i++) {
			int temp; cin >> temp;
			v.push_back(temp);
		}
		int rounds = 0;
		while (!is_end(v)) {
			rounds++;
			game(v);
		}
		cout << rounds << " " << v[0] << endl;
		
	}
	
	
	return 0;
}