有什么足够快的好的哈希方法吗

P3298 [SDOI2013] 泉

@[HWND](/user/487017) 山东人快来帮我(
by DELA @ 2023-09-14 14:08:48


@[TLEWA](/user/515129) 快来帮我(
by DELA @ 2023-09-14 14:39:20


@[DELA](/user/822718) 你这套不够高级呀,要召唤。。。
by _zzzzzzy_ @ 2023-09-14 14:47:40


@[zhangzhengyan0831](/user/715244) 要不你帮我召唤一下(
by DELA @ 2023-09-14 14:48:35


马蜂怪异,南易月读
by xht_G @ 2023-09-14 14:48:43


@[DELA](/user/822718) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432) @[Froranzen](/user/361432)
by _zzzzzzy_ @ 2023-09-14 14:49:42


@[xht_G](/user/823535) 哦不好意思,平时发帖都会先格式化一下,这次忘了格式化了qwq 代码: ``` #include <iostream> using namespace std; long long fact[25], inv[25], invfact[25]; int aa[7000005], bb[7000005]; long long cnt[7000005]; bool vis[7000005]; long long hsh(long long a, long long b, long long c, long long d, long long e, long long f) { return ((a * 1145141145141 + b * 191981019198101 + c * 2333332333331 + d * 2177432177431 + e * 8103098103091 + f * 123456712345671) % 7000001 + 7000001) % 7000001; } long long C(long long n, long long m) { return fact[n] % 998244353 * invfact[m] % 998244353 * invfact[n-m] % 998244353; } void inc(long long a, long long b, long long c, long long d, long long e, long long f) { int i; for (i=hsh(a, b, c, d, e, f); vis[i] && (aa[i] != (a ^ (b << 11) ^ (c << 5) ^ (d << 17) ^ (e << 1) ^ (f << 3)) || bb[i] != (b + (d * 114) + (f * 515))); i+1!=7000001?i++:i=0); if (!vis[i]) aa[i] = (a ^ (b << 11) ^ (c << 5) ^ (d << 17) ^ (e << 1) ^ (f << 3)), bb[i] = (b + (d * 114) + (f * 515)), vis[i] = true; cnt[i]++; } long long query(long long a, long long b, long long c, long long d, long long e, long long f) { int i; for (i=hsh(a, b, c, d, e, f); vis[i] && (aa[i] != (a ^ (b << 11) ^ (c << 5) ^ (d << 17) ^ (e << 1) ^ (f << 3)) || bb[i] != (b + (d * 114) + (f * 515))); i+1!=7000001?i++:i=0); return cnt[i]; } int main() { ios::sync_with_stdio(0); cin.tie(0); long long n, k, a, b, c, d, e, f, summ=0; fact[0] = inv[1] = invfact[0] = 1; for (int i=1; i<=6; i++) (fact[i] = fact[i-1] * i) %= 998244353; for (int i=2; i<=6; i++) inv[i] = (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353; for (int i=1; i<=6; i++) (invfact[i] = invfact[i-1] * inv[i]) %= 998244353; cin >> n >> k; for (int i=1; i<=n; i++) { cin >> a >> b >> c >> d >> e >> f; for (int i=0; i<1<<6; i++) summ += (__builtin_popcount(i) >= k) * (((__builtin_popcount(i) ^ k) & 1) * -2 + 1) * query(i & 1 ? a : -1, i & 2 ? b : -1, i & 4 ? c : -1, i & 8 ? d : -1, i & 16 ? e : -1, i & 32 ? f : -1) * C(__builtin_popcount(i), k), inc(i & 1 ? a : -1, i & 2 ? b : -1, i & 4 ? c : -1, i & 8 ? d : -1, i & 16 ? e : -1, i & 32 ? f : -1); } cout << summ; } ```
by DELA @ 2023-09-14 14:50:46


@[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442) @[oh_my_shy](/user/416442)
by _zzzzzzy_ @ 2023-09-14 14:51:10


但是其实我求助的东西跟代码关系也不大吧(
by DELA @ 2023-09-14 14:51:38


@[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384) @[Link_Cut_Y](/user/519384)
by _zzzzzzy_ @ 2023-09-14 14:51:55


| 下一页