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

· · 题解

include <bits/stdc++.h>

using namespace std;

const int N = 105;

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

int main(){

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;

}