因为 each bucket can contain no more than one element。
代码如下:
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#define CPY(A, B) memcpy(A, B, sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double OO = 1e20;
const double PI = acos (-1.0);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
int x[303],h[303],sum[303];
int main() {
int p,n; bool f=false; scanf ("%d%d",&p,&n);
memset (sum,0,sizeof (sum) );
for (int i=0; i<n; i++) {
scanf ("%d",&x[i]);
h[i]=x[i]%p;
sum[h[i]]++;
if (sum[h[i]]==2) {printf ("%d\n",i+1); f=true; break;}
}
if (!f) { printf ("-1\n"); }
return 0;
}