#include<iostream> #include<cstring> #include<algorithm> #define maxn 2000010 #define maxm 100010 #define ull unsigned long long #define INF 1000000000 usingnamespacestd;
int pri[maxn], cnt, a[maxn]; bool isp[maxn]; voidinit_isp(int n){ a[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, a[i] = i; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; a[i * pri[j]] = pri[j]; if (i % pri[j] == 0) break; } } }
int n, m; int p[maxm]; int g[maxn];
int f[maxn]; voidwork(){ cin >> n >> m; g[0] = 0; for (int i = 1; i <= m; ++i) cin >> p[i], g[0] = max(g[0], p[i]); for (int i = 1; i <= n; ++i) g[i] = 0; for (int i = 1; i <= m; ++i) g[p[i]] = p[i]; for (int i = 1; i <= n; ++i) g[i] = max(g[a[i]], g[i / a[i]]); f[0] = 0; for (int i = 1, j = 0; i <= n; ++i) { while (j < i && (!g[j] || f[j] == INF || j + g[j] - 1 < i)) ++j; f[i] = i == j ? INF : f[j] + 1; } ull mul = 1, ans = 0; for (int i = n; i; --i) { if (f[i] != INF) ans += mul * f[i]; mul *= 23333; } cout << ans << "\n"; }