maximum 10827 torus sum
[LeetCode] 2511. Maximum Enemy Forts That Can Be Captured
You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where: -1 represent ......
Maximum Diameter 题解
[Maximum Diameter](https://www.luogu.com.cn/problem/AT_abc290_f) ### 题目大意 定义长度为 $n$ 的序列 $a$ 的权值为: - 所有的 $n$ 个点的第 $i$ 个点的度数为 $a_i$ 的树的直径最大值,如果不存在这样的树,其 ......
[LeetCode][494]target-sum
# Content You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and ......
[LeetCode][416]partition-equal-subset-sum
# Content Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets i ......
md5sum 文件一致性校验
1. 背景 在网络传输、设备之间转存、复制大文件等时,可能会出现传输前后数据不一致的情况。这种情况在网络这种相对更不稳定的环境中,容易出现。那么校验文件的完整性,也是势在必行的。 md5sum命令用于生成和校验文件的md5值。它会逐位对文件的内容进行校验。是文件的内容,与文件名无关,也就是文件内容相 ......
【CF1519D】Maximum Sum of Products
```cpp #include using namespace std; typedef long long ll; ll n,a[5000+10],b[5000+10],abpre[5000+10],absuf[5000+10],ans; int main(){ cin >> n; for(ll ......
Codeforces Round 892 (Div. 2)E. Maximum Monogonosity(动态规划,数学)
题目链接:https://codeforces.com/contest/1859/problem/E 题意: 有长度为n的a和b俩个序列,定义f【l,r】 = abs(a【l】-b【r】) + abs(b【l】-a【r】); 给正整数k,求 不相交 的 区间 且 所有 区间的长度 的 和 为 k 的 ......
torch.sum()用法-截至2023年8月28日
torch.sum()维度0,1,2。比如现在有$3\times\ 2\times3$的张量,理解为3个$2\times3$的矩阵。当dim=0,1,2时分别在哪个维度上相加[^文艺数学君]?下面是具体的矩阵 $$ [1,2,3]\\ [4,5,6]\\\\ [1,2,3] \\ [4,5,6]\\ ......
Leetcode 15. 三数之和(3Sum)
[题目链接](https://leetcode.cn/problems/3sum) 给你一个整数数组 nums ,判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i != j、i != k 且 j != k ,同时还满足 nums[i] + nums[j] + nu ......
AT_agc030_d [AGC030D] Inversion Sum 题解
# AT_agc030_d [AGC030D] Inversion Sum 题解 ## 题目大意 给你一个长度为 $n$ 的数列,然后给你 $q$ 次交换操作,你每次可以选择操作或者不操作,问所有情况下逆序对的总和。($n, q \le 3000$) ## 分析 很容易想到 $dp$,但是发现不好直 ......
CF979D Kuro and GCD and XOR and SUM
### 题目大意 初始有一个空的集合,和 $Q$ 个操作。对于每个操作,有两种类型,分别用如下的两种形式表示: `1 u`:加入 $u$ 到集合 `2 x k s`:求一个最大的 $v$,使得: 1. $v+x \leq s$ 2. $k \mid \gcd(v,x)$ 3. $x \oplus v ......
001_two_sum
准备工作 安装vscode(并安装其leetcode插件)、nodejs环境。 问题描述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答 ......
Leetcode 454. 四数相加 II(4sum ii)
[题目链接](https://leetcode.cn/problems/4sum-ii) 给你四个整数数组 nums1、nums2、nums3 和 nums4 ,数组长度都是 n ,请你计算有多少个元组 (i, j, k, l) 能满足: - 0 nums1[0] + nums2[0] + nums ......
CF1442D-Sum
# [Sum](https://codeforces.com/problemset/problem/1442/D) You are given $n$ non-decreasing arrays of non-negative numbers. Vasya repeats the following ......
[AGC030D] Inversion Sum
### 题目大意 一个长度为 $n$ 的数列,然后给你 $q$ 个交换或不交换操作,你可以选择操作或者不操作,问所有情况下逆序对的总和。 答案需要对 $10 ^ 9 + 7$ 取模。 ($n\leq 3000$,$q\leq 3000$)。 ### 思路 这道题非常巧妙。 我们先考虑转化题意,求逆序 ......
[AGC030D] Inversion Sum 题解
## 题意 给定一个长度为 $n$ 的排列 $a$ 和 $m$ 个形如 $\left(x,y\right)$ 的操作,每次操作可以选择是否交换 $a_x, a_y$,求最终所有形成的排列的逆序对总数。 ($1 \le n,m \le 3000$)。 ## 题解 考虑转化题意,考虑求出最终总的期望逆序 ......
[LeetCode][152]maximum-product-subarray
# Content Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the ......
[LeetCode][124]binary-tree-maximum-path-sum
# Content A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can onl ......
mysql导入sql文件“Index column size too large. The maximum column size is 767 bytes.”
问题分析 由于 MySQL 的 InnoDB 引擎表索引字段长度的限制为 767 字节,因此对于多字节字符集的大字段或者多字段组合,创建索引时会出现该问题。 说明 注:以 utf8mb4 字符集字符串类型字段为例。utf8mb4 是 4 字节字符集,默认支持的索引字段最大长度是 191 字符(767 ......
Leetcode 1. 两数之和(Two sum)
[题目链接🔗](https://leetcode.cn/problems/two-sum) 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素 ......
P1466 Subset Sum
对于从 1∼n 的连续整数集合,能划分成两个子集合,且保证每个集合的数字和是相等的 求可以划分的方案数 ###1. 动态规划 ``` long long maxval(int n){ int sum = (1+n)*n/2; if(sum%2==1) return 0; vector dp(sum+ ......
MySQL SUM() 带条件的求和方法与多条件的求和方法
一、单一的求和。 select sum(value) as value from table where user_id = 1 and type = 6 and type_son = 2value 为求和的字段。 as 后面是 sum 求和后给它一个名称。 二、SQL语句中嵌套语句多条件求和。 s ......
js 计算对象数组中某个字段sum之和
1、一个字段之和 要计算一个对象数组中某个字段的和,你可以使用 JavaScript 的 Array.prototype.reduce() 方法。reduce() 方法对数组中的每个元素执行一个提供的函数,并将结果累积为单个值。以下是一个示例: 假设你有一个对象数组 data,每个对象都有一个 va ......
[ABC238E]Rcange Sums
## 前言 一道水得不能再水的题,虽说在图论的题单里,但我真的没有用图,用了并查集就轻松$AC$。 ## 大意 输入$q$个$l,r$,表示知道$l$到$r$的区间,最后问能不能知道$0$到$n$,能就输出`Yes`,不能就输出`No`。 ## 思路 1. 图论做法:可以把知道$l$到$r$的区间抽 ......
[ABC098D] Xor Sum 2 题解
### 题解 [传送门](https://luogu.com.cn/problem/at_abc176_d) #### 题目大意 给出一个序列 $A$ ,求 $A_l \oplus A_{l+1} \oplus \dots \oplus A_r = A_l + A_{l + 1} +\dots+ A ......
[AGC056D] Subset Sum Game
# [[AGC056D] Subset Sum Game](https://www.luogu.com.cn/problem/AT_agc056_d) ## 一、题目大意: 一块黑板上写着 $n$ 个整数。第 $i$ 个整数记作 $a_i$。保证 $n$ 是偶数。此外,给定 $L,R$。 Alice ......
CF1762E Tree Sum 题解
## 题意 对于一棵 $n$ 个节点的树 $T$,定义 $\operatorname{good}(T)$ 为真当且仅当边权 $w \in \left\{-1,1\right\}$ 且对于任意节点 $u$,均有 $\displaystyle f(u) = \prod\limits_{\left(u, ......
使用MD5算法和sha512sum校验和检验文件完整性
[TOC] # 一.前言 在我们日常生活中,无论是下载文件、传输数据还是备份重要信息,如何确保数据的完整性始终是一个不能忽视的问题。本文将向大家介绍如何使用MD5算法和sha512sum校验和来进行文件完整性的验证。 # 二.MD5算法简介 MD5算法,全称Message-Digest Algori ......
[口胡记录] AGC020C Median Sum
([题目传送门](https://www.luogu.com.cn/problem/AT_agc020_c)) 一开始口胡结论,发现假了…… 把所有的子集和放到数轴上,惊奇地发现它们关于 $\dfrac{sum}{2}$ 对称,于是做一遍存在性背包,从 $\dfrac{sum}{2}$ 开始找第一个 ......
[LeetCode][53]maximum-subarray
# Content Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Ou ......