手写哈希,调了一个小时没调出来,急死我了
本人若无法及时回复,请谅解
记录
代码
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e7 + 19;
bool a[mod];
void hashi(int x) {
if (!a[(x % mod + mod) % mod]) a[(x % mod + mod) % mod] = true, cout << x << " ";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
memset(a, 0, sizeof(a));
int n, x;
cin >> n;
for (int i = 1; i <= n; i++) cin >> x, hashi(x);
cout << endl;
}
return 0;
}