1.素数
2.平方探测法
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N = 1e4+5;
bool isPrime(int n) {
if(n <= 1) return false;
for(int i=2; i<=sqrt(n); i++) {
if(n%i == 0) return false;
}
return true;
}
int main() {
int key, n;
cin >> key >> n;
while(!isPrime(key)) {
key++;
}
bool hash[key];
memset(hash, false, sizeof(hash));
for(int i=0; i<n; i++) {
if(i>0){
cout << " ";
}
int tmp, j;
cin >> tmp;
for(j=0; j<key; j++) {
int t = (tmp+j*j)%key;
if(!hash[t]) {
hash[t] = true;
cout << t;
break;
}
}
if(j == key) {
cout << "-";
}
}
cout << endl;
return 0;
}