R = lambda : map(int, input().split()) for _ in range(int(input())) : a, b, c, d = R() print(b, c, c)
B - Kana and Dragon Quest game
题意: 将一个数进行向下取整减半再加10, 或者减10, 问能够将数在限制内得到小于等于0
题解: 贪心地想,先进行第一种操作, 到不能使数更小, 则用第二种操作
1 2 3 4 5 6 7 8 9 10 11 12
R = lambda : map(int, input().split()) for _ in range(int(input())) : x, n, m = R() while x > 0and n : if x // 2 + 10 > x : break x = x // 2 + 10 n -= 1 while x > 0and m : x -= 10 m -= 1 print("YES"if x <= 0else"NO")
constdouble P = acos(-1.0), eps = 1e-9; structpoint { db x ,y;}; inlineintsign(db a){return a < -eps ? -1 : a > eps;} #define dot(p1,p2,p3) ((p2.x-p1.x)*(p3.x-p1.x)+(p2.y-p1.y)*(p3.y-p1.y)) #define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y)) #define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))
constint Ma = 2e5 + 100, inf = 0x3f3f3f3f, mod = 1e9 + 7;
vector<int> g[Ma]; int son[Ma], val[Ma]; voiddfs(int u, int fa, int dp){ rap (i, g[u]) if (i != fa) { dfs(i, u, dp + 1); son[u] += son[i] + 1; } val[u] = son[u] - dp; }
signedmain(){ #if SYNC==0 ios::sync_with_stdio(false); cin.tie(0); #endif int n, k; cin >> n >> k; rep (i, n - 1) { int u, v; cin >> u >> v; g[u].ep(v); g[v].ep(u); } dfs(1, -1, 0); nth_element(val + 1, val + k + 1, val + n + 1); cout << accumulate(val + k + 1, val + n + 1, 0ll) << endl; return0; }
D - Xenia and Colorful Gems
题意: 给你三种颜色的宝石, 让你从三种颜色中各挑一个, 得到x, y, z, \((x-y)^2+(y-z)^2+(z-x)^2\)最小
题解: 假设 x <= y <= z, 那么固定y, x就是对应序列中最大的小于y的宝石, z就是对应序列中最小的不小于y的宝石
constint Ma = 3300, inf = 0x3f3f3f3f, mod = 998244353;
int dp[Ma][Ma]; char s[Ma], t[Ma];
signedmain(){ #if SYNC==0 ios::sync_with_stdio(false); cin.tie(0); #endif cin >> s >> t; int n = strlen(s), m = strlen(t); fep (i, 1, n + 2) dp[i][i - 1] = 1; for (int i = 1; i <= n; ++i) { for (int l = 1; l < n - i + 2; ++l) { int r = l + i - 1; if (s[i - 1] == t[l - 1] or !t[l - 1]) (dp[l][r] += dp[l + 1][r]) %= mod; if (s[i - 1] == t[r - 1] or !t[r - 1]) (dp[l][r] += dp[l][r - 1]) %= mod; } } ll ans = 0; fep (i, m, n + 1) (ans += dp[1][i]) %= mod; cout << ans << endl; return0; }