求助,全 wa,0 pts !!!
查看原帖
求助,全 wa,0 pts !!!
842408
pangyuchen75楼主2023/12/23 15:23
#include <cstdio>
#define N 100005
#define mod 1000000007
using namespace std;

int n;
int a[N];
int tot[N];
int ans;

int main() {
	scanf("%d", &n);
	
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		++tot[a[i]];
	}
	
	for(int i = 5000; i > 0; --i) {
		if(tot[i] < 2)
			continue;
		
		for(int j = 5000; j > 0; --j) {
			if(!tot[j])
				continue;
				
			
			if(i - j < 1)
				continue;
			
			if(!tot[i - j])
				continue;
			
			++ans;
		}
	}
	
	printf("%d\n", ans % mod);
	
	return 0;
}
2023/12/23 15:23
加载中...