题目: https://pintia.cn/problem-sets/15/problems/889
思路: 简单的散列映射,直接上代码
#include <iostream>
using namespace std;
int hashTable[1005];
int main() {
int n,p; cin>>n>>p;
for(int i = 0;i < n;i++){
int c;cin>>c;
int s = c % p;
while(hashTable[s] != c && hashTable[s]) s = (s+1) % p;
hashTable[s] = c;
cout<<s<<(i == n-1 ? "\n" : " ");
}
return 0;
}