A:签到。

#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 110
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,a[N],s,ans=0;
int calc(int k){return abs(s-a[k]*n);}
int main()
{
/*#ifndef ONLINE_JUDGE
    freopen("a.in","r",stdin);
    freopen("a.out","w",stdout);
    const char LL[]="%I64d\n";
#else
    const char LL[]="%lld\n";
#endif*/
    n=read();
    for (int i=1;i<=n;i++) s+=a[i]=read();
    for (int i=2;i<=n;i++)
    if (calc(i)<calc(ans+1)) ans=i-1;
    cout<<ans;
    return 0;
}
View Code

相关文章:

  • 2021-12-11
  • 2022-02-21
  • 2021-12-18
  • 2022-12-23
  • 2022-02-06
  • 2022-02-20
  • 2021-08-04
猜你喜欢
  • 2021-12-23
  • 2021-07-23
  • 2021-12-19
  • 2021-05-20
  • 2022-01-28
  • 2022-01-19
  • 2021-11-07
相关资源
相似解决方案