用洛谷IDE与本地输出竟然完全不一样,有大佬解释一下吗
by mrchen116 @ 2018-11-29 13:36:37
@[mrchen116](/space/show?uid=49953) 初始化?
by Rocket_raccoon_ @ 2018-11-29 13:41:27
show the code
by Rocket_raccoon_ @ 2018-11-29 13:41:41
```cpp
#include<cstdio>
#include<algorithm>
#define hash(x) (x%1000003)
using namespace std;
struct ooo{
int v,num;
ooo(int v=EOF,int num=0):v(v),num(num) {}
}m[1000003];
int n,c,a[200000];
int read()
{
int p=0;
char ch=getchar();
while(ch<='9'&&ch>='0')
{
p=p*10+ch-'0';
ch=getchar();
}
return p;
}
int find(int v)
{
int key=hash(v);
while(m[key].v!=v&&m[key].num)
{
key=hash(key+1);
}
return key;
}
int main()
{
n=read(),c=read();
int t;
long long ans=0;
for(int i=0;i<n;i++)
{
a[i]=read();
t=find(a[i]);
m[t].v=a[i];
m[t].num++;
a[i]-=c;
}
for(int i=0;i<n;i++)
if(a[i]>=0)
{
ans+=m[find(a[i])].num;
}
printf("%lld\n",ans);
return 0;
}
```
**input**
10 3
10 4 7 5 10 4 5 8 5 7
**本地:**11
**洛谷:**7
by mrchen116 @ 2018-11-30 00:42:30
@[Rocket_raccoon_](/space/show?uid=39533)
by mrchen116 @ 2018-11-30 00:43:22
洛谷IDE环境不同
by Atmizz @ 2019-05-12 20:23:12