比赛 NOIP模拟赛by mzx Day1 评测结果 MMMMMMMMMM
题目名称 为爱追寻 最终得分 0
用户昵称 再见 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2016-10-19 21:56:34
显示代码纯文本
#include<cstdio>
#include<cstdlib>
#include<cctype>

const char str[]={"SingleDogMZX"};

inline long long read(){
	long long _x=0; char ch; bool flag=false;
	while(ch=getchar(),!isdigit(ch)) ch=='-'?flag=true:false;
	while(_x=_x*10+ch-'0',ch=getchar(),isdigit(ch));
	return flag?-_x:_x;
}

int n,ans,findans=0;
long long int x,y,xx,yy,dx,dy;

long long hash[20000000][3],MOD=10000007;


int gethash(long long ax,long long ay){
	ax=(ax+MOD)%MOD; ay=(ay+MOD)%MOD;
	long long pp=(ax%10007)*59627+(ay%75627)*10007;
	int p=(pp+MOD)%MOD;
	if(p<0) p=(-p)%MOD;
	while(true){
		if(!hash[p][0]) break;
		if(hash[p][1]==ax&&hash[p][2]==ay) break;
		p=(p+1)%MOD;
	}
	if(hash[p][0]==0){
		hash[p][0]=1;
		hash[p][1]=ax;
		hash[p][2]=ay;
		return true;
	}
	else return false;
}

int main()
{
	//freopen("a.txt","r",stdin);
	freopen("loverfinding.in","r",stdin);
	freopen("loverfinding.out","w",stdout);
	scanf("%d",&n); x=read(); y=read(); xx=read(); yy=read();
	if(gethash(x,y)) ans++;
	for(int i=1;i<=n;i++){
		dx=read(); dy=read();
		x+=dx; y+=dy;
		if(x==xx&&y==yy){
			findans=true;
			break;
		}
		if(gethash(x,y)) ans++;
	}
	if(findans) printf("%d",ans+1);
	else printf("%s",str);
	return 0;
}