P1031 均分纸牌

https://www.luogu.com.cn/problem/P1031

 

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

int n,s;
int a[105];

signed main() {
    //freopen("in","r",stdin);
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i],s+=a[i];
    s /= n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(a[i] - s){
            a[i + 1] += a[i] - s;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}
View Code

posted @ 2020-02-26 17:12  Hazelxcf  阅读(134)  评论(0)    收藏  举报