第四个点不是re就是wa,求大佬帮忙改改代码吧
查看原帖
第四个点不是re就是wa,求大佬帮忙改改代码吧
181715
gjh303987897楼主2021/11/30 17:20
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 1000003
using namespace std;
const unsigned long long mod=904736;
typedef unsigned long long ULL;
struct data{
    ULL tot,x;
}t[maxn];
ULL n,c;
ULL a[maxn],ans;
void deal(ULL x){
    ULL i=x%mod;
    while(t[i].tot!=0&&t[i].x!=x) i=(i+1)%mod;
    t[i].tot++; t[i].x=x;
}
void ask(ULL x){
    ULL i=x%mod;
    if(t[i].tot!=0){
        ans+=t[i].tot;
    }
}
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        deal(a[i]);
    }
    for(int i=1;i<=n;i++){
        ask(a[i]+c);
    }
    cout<<ans;
    return 0;
}
2021/11/30 17:20
加载中...