[2016-04-13][codeforces][447][A][DZY Loves Hash].md
-
时间:2016-04-13 23:35:11 星期三
-
题目编号:[2016-04-13][codeforces][447][A][DZY Loves Hash]
-
题目大意:问hash是否冲突
-
分析:模拟一遍即可
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 300 + 10;
int a[maxn];
int main(){
int p,n,tmp;
memset(a,-1,sizeof(a));
scanf("%d%d",&p,&n);
for(int i = 0; i < n ; ++i){
scanf("%d",&tmp);
if(a[tmp % p] != -1){
printf("%d\n",i+1);
return 0;
}else a[tmp%p] = tmp;
}
printf("-1\n");
return 0;
}
时间: 2024-10-12 15:58:22