点4re求调,不理解,为什么会re
查看原帖
点4re求调,不理解,为什么会re
1162380
liverxiwo楼主2024/5/22 12:48
#include<bits/stdc++.h>
#define int long long
const int mod=1e9+7;
using namespace std;
int n,c;
int a[1000005],ans;
struct node{
	int x,y;
}h[1000005];
inline int find(int x){
	int y=abs(x)%mod;
	while(h[y].x&&h[y].x!=x){
		y=(++y)%mod;	 
	}
	return y;
}
inline void push(int x){
	int y=find(x);
	h[y].y++;
	h[y].x=x;
	return ;
}
inline int check(int x){
	return h[find(x)].y;
}
signed main(){
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		push(a[i]);
	}
	for(int i=1;i<=n;i++){
		ans+=check(a[i]-c);
	}
	printf("%lld",ans);
	return 0;
} 
2024/5/22 12:48
加载中...