Codeforces Round #FF (Div. 2), problem: (A) DZY Loves Hash editorial: http://codeforces.com/blog/entry/13036
Codeforces Round #FF (Div. 2), problem: (A) DZY Loves Hash solution: http://ideone.com/EZ6IdH
#include <iostream> #include <cstdio> using namespace std; int main() { int p, n, x, a[305], idx=-1; for(int i=0; i<305; i++) a[i]=0; scanf("%d%d", &p, &n); for(int i=0; i<n; i++) { scanf("%d", &x); if(a[x%p]==0) a[x%p]++; else { idx=i+1; break; } } printf("%d", idx); return 0; }
No comments:
Post a Comment