牛客周赛 Round 63

news/2024/10/14 0:22:51

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ryyt.cn/news/71281.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

Dockerr安装Oracle以及使用DBeaver连接

拉取镜像 pull container-registry.oracle.com/database/free:latest创建容器说明一下我现在的最新版本是23docker run -d --name oracle23i -h xrilang -p 1521:1521 container-registry.oracle.com/database/free:latest查看日志 docker logs oracle23i设置密码 因为创建容器…

数据结构 - 栈

栈是一种特殊线性数据结构,操作遵循后进先出原则,可解决表达式求值等问题。栈分为顺序栈和链栈,各有特点。文章详细介绍了栈的定义、分类及实现方式,包括顺序栈和链栈的ADT定义及基本操作实现。栈一种常见的特殊线性数据结构,其特殊之处在于其操作顺序,下面会详细介绍,也…

《使用Gin框架构建分布式应用》阅读笔记:p20-p31

《用Gin框架构建分布式应用》学习第2天,p20-p31总结,总计12页。 一、技术总结 1.第一个gin程序 // main.go package mainimport "github.com/gin-gonic/gin"func main() {r := gin.Default()r.GET("/", func(c *gin.Context) {c.JSON(200, gin.H{"m…

hot100 review

56. 合并区间 https://leetcode.cn/problems/merge-intervals/description/?envType=study-plan-v2&envId=top-100-liked 该怎么排序区间 vector<vector>& intervals sort(intervals)即可 238. 除自身以外数组的乘积 https://leetcode.cn/problems/product-of-a…

inline、const、mutable、this、static

inline、const、mutable、this、static 在类定义中实现成员函数 incline成员函数末尾的 const(声明和实现中都要加上 const) 作用:告诉系统,这个成员函数不会修改该对象里任何成员变量的值等等,也就是说,这个成员函数不会修改类 Time的任何状态。===> 也叫做常量成员函…

吴恩达机器学习笔记(2-1到2-7)

吴恩达机器学习笔记(2-1到2-7) https://www.bilibili.com/video/BV164411b7dx?p=5 https://www.bilibili.com/video/BV164411b7dx?p=6 https://www.bilibili.com/video/BV164411b7dx?p=7 https://www.bilibili.com/video/BV164411b7dx?p=8 https://www.bilibili.com/vide…

网络安全问题

Linux:在配置Centos7时,刚开始yum不能使用,原因是它默认使用的是自带的yum源,但是这个yum源很不稳定 解决方法:将其换成国内源yum的配置文件在/etc/yum.repos.d/CentOS-Base.repo当中,我们将其切换成阿里云镜像使用这个语句:curl -o /etc/yum.repos.d/CentOS-Base.repo …

分布式事务之Seata的AT模型

在Seata的事务管理中有三个重要的角色:TC (Transaction Coordinator) - 事务协调者:维护全局和分支事务的状态,协调全局事务提交或回滚。 TM (Transaction Manager) - 事务管理器:定义全局事务的范围、开始全局事务、提交或回滚全局事务。 RM (Resource Manager) - 资源管理…