1 条题解

  • 1
    @ 2022-11-30 8:09:06
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n,h[27]={0},i,j,s=0;
        cin>>n;
        int a[53]={0};
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(h[a[i]+a[j]]==0){
                    s++;
                    h[a[i]+a[j]]=1;
                }
            }
        }
        cout<<s<<endl;
        bool f=false;
        for(i=1;i<27;i++){
            if(h[i]==1){
                if(f) cout<<" ";
                else f=true;
                cout<<i;
            }
        }
        return 0;
    }
    
    • 1

    信息

    ID
    331
    时间
    1000ms
    内存
    16MiB
    难度
    9
    标签
    递交数
    8
    已通过
    8
    上传者