A.小红的好数
题意:
满足数位为2, 且个位数和十位数相等
思路:
通过输入字符串, 首先判断字符串的个数是否为2, 在判断个位数和十位数是否相等
Code:
#include <bits/stdc++.h>using namespace std; using i64 = int64_t; void solve() {string s;cin >> s;if (s[0] == s[1] && s.size() == 2) {cout << "Yes\n";} else {cout << "No\n";} }int main() {cin.tie(0) -> sync_with_stdio(false);int t = 1;// cin >> t;while (t--) {solve();}return 0; }
D:小红的行列式构造
题意:
构造一个3阶行列式, 满足每个元素的绝对值不小于1, 且最后的值等于x
思路:
[a, b, c] [d, e, f] [g, h, i]-> a * e * i + b * f * g + c * d * h - a * f * h - b * d * i - c * e * g -> a * (e * i - f * h) + b * (f * g - d * i) + c * (d * h - e * g)假设 a, b, c都是相同的, 那么我们令它们为1 -> 1 * (e * i - f * h) + 1 * (f * g - d * i) + 1 * (d * h - e * g) -> d * (h - i) + e * (g - i) + f * (g - h)如果假设d, e, f都是相同导致最终的结果为0, 也就是得到一个结论 如果a, b, c相同且d, e, f相同最终结果一定为0那么我们只能在d, e, f挑不是相同, 那么e, f 为1, d为2, 通过计算式子可以得到 -> 2 * (h - i) + 1 * (g - i) + 1 * (g - h) -> 2 * (h - i) + g - i - g + h - i -> 2 * (h - i) + 0 h - i = x 那么只要满足这个式子都可以, 那么我可以假设i = 101那么我的h就是x + 101 为什么不能是x + (值 < 101) 是因为行列式的值的绝对值需要大于等于x也就因为这, 最小情况只能是[g, x + 101 x] 其次发现g在这个式子是直接被约掉的, 那么abs(g) >= 1的值都可以 那么这题就顺利解决了
Code:
#include <bits/stdc++.h>using namespace std; using i64 = int64_t; void solve() {int x;cin >> x;if (x == 0) {cout << "1 1 1\n1 1 1\n1 1 1\n";} else {cout << "1 1 1\n2 1 1\n" << 2 << ' ' << x * 2 << ' ' << x << '\n';} }int main() {cin.tie(0) -> sync_with_stdio(false);int t = 1;// cin >> t;while (t--) {solve();}return 0; }
2