#include<cstdio>#include<cstring>#include<algorithm>
using namespace std;
inlineintread() {
int x = 0, f = 1; char s = getchar();
while (s < '0' || s > '9') { if (s == '-') f = -f; s = getchar(); }
while (s >= '0' && s <= '9') { x = x * 10 + s - '0'; s = getchar(); }
return x * f;
}
constint SIZE = 1e7 + 500;
bool ori[SIZE + 10];
bool f[SIZE + 10];
int go[SIZE + 10];
voidprework(int N) {
for (int i = 1; i <= N; i ++)
ori[i] = ori[i / 10] | (i % 10 == 7);
for (int i = 1; i <= N; i ++) {
if (!ori[i]) continue;
if (f[i]) continue;
for (int j = i; j <= N; j += i) f[j] = 1;
}
for (int i = N; i >= 1; i --)
if (f[i])
go[i] = go[i + 1];
else
go[i] = i;
}
voidwork() {
int x = read();
if (f[x])
puts("-1");
elseprintf("%d\n", go[x + 1]);
}
intmain() {
prework(SIZE);
int T = read();
while (T --)
work();
return0;
}
// I hope changle_cyx can pray for me.
#include<cstdio>#include<cstring>#include<algorithm>
using namespace std;
inlineintread() {
int x = 0, f = 1; char s = getchar();
while (s < '0' || s > '9') { if (s == '-') f = -f; s = getchar(); }
while (s >= '0' && s <= '9') { x = x * 10 + s - '0'; s = getchar(); }
return x * f;
}
intpower(int a, int b, int p) {
int ans = 1;
for (; b; b >>= 1) {
if (b & 1) ans = 1ll * ans * a % p;
a = 1ll * a * a % p;
}
return ans;
}
constint N = 35, M = 110;
constint mod = 998244353;
voidadd(int &x, constint &y) {
x += y;
if (x >= mod) x -= mod;
}
int n, m, k;
int val[M];
int fact[N], inv[N];
intC(int n, int m) {
return1ll * inv[n - m] * inv[m] % mod * fact[n] % mod;
}
int f[M][N][N][N];
int cnt[N];
intmain() {
n = read(), m = read(), k = read();
for (int i = 0; i <= m; i ++)
val[i] = read();
fact[0] = 1;
for (int i = 1; i <= n; i ++) fact[i] = 1ll * fact[i - 1] * i % mod;
inv[n] = power(fact[n], mod - 2, mod);
for (int i = n - 1; i >= 0; i --) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
for (int x = 0, cur = 1; x <= n; x ++, cur = 1ll * cur * val[0] % mod)
f[0][x][x % 2][x / 2] = cur;
for (int i = 1; i <= m; i ++) {
for (int x = 0, cur = 1; x <= n; x ++, cur = 1ll * cur * val[i] % mod) {
for (int j = x; j <= n; j ++) {
for (int h = 0; h <= n; h ++) {
for (int S = 0; S <= n; S ++) {
if (!f[i - 1][j - x][h][S]) continue;
int d = 1ll * f[i - 1][j - x][h][S] * C(j, x) % mod * cur % mod;
add(f[i][j][h + (S + x) % 2][(S + x) / 2], d);
}
}
}
}
}
for (int S = 1; S <= n; S ++)
cnt[S] = cnt[S ^ (S & -S)] + 1;
int ans = 0;
for (int h = 0; h <= n; h ++)
for (int S = 0; S <= n; S ++)
if (h + cnt[S] <= k) add(ans, f[m][n][h][S]);
printf("%d\n", ans);
return0;
}
#include<cstdio>#include<cstring>#include<algorithm>
using namespace std;
inlineintread() {
int x = 0, f = 1; char s = getchar();
while (s < '0' || s > '9') { if (s == '-') f = -f; s = getchar(); }
while (s >= '0' && s <= '9') { x = x * 10 + s - '0'; s = getchar(); }
return x * f;
}
constint N = 10010, SZ = 500100;
constint inf = 0x3f3f3f3f;
int n, m, L, res;
int a[N], b[N];
int sum[N];
int p, q;
int f[2][SZ];
intmain() {
n = read();
for (int i = 1; i <= n; i ++)
a[i] = read(), m = max(m, a[i]);
L = n * m;
for (int i = 1; i < n; i ++) {
b[i] = a[i + 1] - a[i];
if (!b[i]) res ++;
}
sort(b + 1, b + n);
for (int i = 1; i < n; i ++)
sum[i] = sum[i - 1] + b[i];
p = 0, q = 1;
f[p][0] = 0;
for (int S = 1; S <= L; S ++) f[p][S] = inf;
for (int i = res + 1; i < n; i ++) {
p ^= 1, q ^= 1;
for (int S = 0; S <= L; S ++) f[p][S] = inf;
for (int S = 0; S <= L; S ++) {
f[p][S + sum[i]] = min(f[p][S + sum[i]], f[q][S] + sum[i] * sum[i]);
f[p][S + b[i] * i] = min(f[p][S + b[i] * i], f[q][S] + 2 * S * b[i] + i * b[i] * b[i]);
}
}
longlong ans = 1e18;
for (int S = 0; S <= L; S ++)
ans = min(ans, 1ll * n * f[p][S] - 1ll * S * S);
printf("%lld\n", ans);
return0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】