赠送题解
查看原帖
赠送题解
1375504
Zhang_LingYun楼主2024/9/22 18:33
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[1001],q[100001],n,temp=0,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        q[a[i]]=1;
    }
    for(int i=1;i<n;i++){
    	for(int j=i+1;j<=n;j++){
        	temp=a[i]+a[j];
        	if(q[temp]){ans++;q[temp]=0;}
    	}
	}
    cout<<ans;
    return 0;
}
2024/9/22 18:33
加载中...