让你找离平均数最近的一个数的下标;
判断的时候,平均数和枚举的数都乘上n;
这样精度比较高;避免小数比较;
0
empty
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e3;
int a[N+100],n,sum,mi,idx;
int main(){
//Open();
//Close();
scanf("%d",&n);
rep1(i,1,n){
scanf("%d",&a[i]);
sum+=a[i];
}
mi = abs(sum-a[1]*n),idx = 1;
rep1(i,2,n){
int temp = abs(sum-a[i]*n);
if (temp < mi){
mi = temp;
idx = i;
}
}
cout << idx << endl;
return 0;
}
/*
写完之后,明确每一步的作用
*/