#include <bits/stdc++.h> #include "dzilib.h" using namespace std; using ll = long long; #ifdef LOCAL #include "debug.h" #else #define debug(...) 2137 #endif using H = uint64_t; const H MOD = (1ll << 61) - 1; const H B = 11112137; H add(H x, H y) { return x + y >= MOD ? x + y - MOD : x + y; } H sub(H x, H y) { return add(x, MOD - y); } H mul(H x, H y) { return (__uint128_t)x * y % MOD; } const int N = 1000300; const int K = 100; int n, t; int d[N]; H h[N], p[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); n = GetN(); t = GetT(); for (int i = 1; i <= n + K; i++) { for (int j = i; j <= n + K; j += i) { d[j]++; } } p[0] = 1; for (int i = 0; i <= n + K; i++) { p[i + 1] = mul(p[i], B); h[i + 1] = add(mul(h[i], B), d[i]); } map<H, int> mp; for (int i = 1; i <= n; i++) { mp[sub(h[i + K], mul(h[i], p[K]))] = i; } while (t--) { H x = 0; for (int i = 0; i < K; i++) { x = add(mul(x, B), Ask(i)); } Answer(mp[x]); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <bits/stdc++.h> #include "dzilib.h" using namespace std; using ll = long long; #ifdef LOCAL #include "debug.h" #else #define debug(...) 2137 #endif using H = uint64_t; const H MOD = (1ll << 61) - 1; const H B = 11112137; H add(H x, H y) { return x + y >= MOD ? x + y - MOD : x + y; } H sub(H x, H y) { return add(x, MOD - y); } H mul(H x, H y) { return (__uint128_t)x * y % MOD; } const int N = 1000300; const int K = 100; int n, t; int d[N]; H h[N], p[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); n = GetN(); t = GetT(); for (int i = 1; i <= n + K; i++) { for (int j = i; j <= n + K; j += i) { d[j]++; } } p[0] = 1; for (int i = 0; i <= n + K; i++) { p[i + 1] = mul(p[i], B); h[i + 1] = add(mul(h[i], B), d[i]); } map<H, int> mp; for (int i = 1; i <= n; i++) { mp[sub(h[i + K], mul(h[i], p[K]))] = i; } while (t--) { H x = 0; for (int i = 0; i < K; i++) { x = add(mul(x, B), Ask(i)); } Answer(mp[x]); } } |