跳到正文

题解

题解:P1031 [NOIP 2002 提高组] 均分纸牌

sunyuxuanqq约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年2月23日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 1 分钟
获赞
1
题目
P1031

版本

  1. v1当前

#include <bits/stdc++.h> using namespace std;

const int N = 105;

int n, a[N], cnt, s;

int main(){

C++
cin >> n;
for(int i = 1; i <= n; i++){
	cin >> a[i];
	s+=a[i];
}
s/=n;
for(int i = 1; i <= n; i++){
	int t = s-a[i];
	if(t){
		a[i+1] -= t;
		cnt++;
		
	}
}
cout << cnt;
return 0;

}

原文