比赛 |
NOIP模拟赛by mzx Day1 |
评测结果 |
AAAWWWEEEE |
题目名称 |
为爱追寻 |
最终得分 |
30 |
用户昵称 |
sro dydxh orz |
运行时间 |
4.464 s |
代码语言 |
C++ |
内存使用 |
76.61 MiB |
提交时间 |
2016-10-19 19:21:28 |
显示代码纯文本
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stdio.h>
#include<cstdlib>
#include<iomanip> //cout<<setiosflags(ios::fixed)<<setprecision(2);
#include<ctime> //double a=(double)clock(); cout<<a<<endl;
#include<vector>
#include<queue>
using namespace std;
const int MOD=9999997,step=7,muti_x=631,muti_y=1031;
int n,xo,yo,xt,yt,same;
struct hash
{
int x,y;
}h[10000002];
void insert(int xx,int yy)
{
int at=(1LL*xx*muti_x+1LL*yy*muti_y)%MOD;
while(1)
{
if(h[at].x==-1&&h[at].y==-1)
break;
if(h[at].x==xx&&h[at].y==yy)
break;
at+=step;
if(at>MOD)
at-=MOD;
}
if(h[at].x==xx&&h[at].y==yy)
same--;
h[at].x=xx,h[at].y=yy;
//cout<<same<<endl;
}
void init(){
for(int i=0;i<=10000000;i++)
h[i].x=h[i].y=-1;
}
int main()
{
freopen("loverfinding.in","r",stdin);
freopen("loverfinding.out","w",stdout);
init();
scanf("%d%d%d%d%d",&n,&xo,&yo,&xt,&yt);
for(int i=1;i<=n;i++){
//cout<<i<<endl;
int dx,dy;
scanf("%d%d",&dx,&dy);
xo+=dx;//
yo+=dy;//
if(xo==xt&&yo==yt)break;
same++;
insert(xo,yo);
}
cout<<same+2<<endl;
//fclose(stdin),fclose(stdout);
return 0;
}