您当前处于兼容模式。某些功能在此模式下不可用。我们强烈建议在现代浏览器上切换为标准模式以获得更好的体验。 标准模式 隐藏

#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<long long>a(n);
    long long sum=0,mx=0,mn=1e9;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        mx=max(mx,a[i]);
        mn=min(mn,a[i]);
    }
    for (int k=n;k>=1;k--){
        if (k==n) {
            if(mx*n==sum) {
                cout<<k;
                return 0;
            }
            continue;
        }
        long long up=(sum-k*mx)/(n-k);
        if (up>mn){
        	up=mn;
		}
        bool found=0;
        for (long long x=up;x>=0;x--){
            if((sum-n*x)%k==0){
                found=1;
                break;
            }
        }
        if(found){
            cout<<k;
            return 0;
        }
    }
    cout<<"1";
    return 0;
}

2 条评论

  • @ 2026-8-18 8:01:41

    求调

    • @ 2026-1-24 17:35:48

      啊啊啊

      👍 2
      ❤️ 2
      🤔 2
      🤣 2
      😄 2
      😕 2
      🌿 2
      🕊️ 2
      • 1

      信息

      ID
      53
      时间
      ms
      内存
      MiB
      难度
      10
      标签
      (无)
      递交数
      7
      已通过
      2
      上传者