sum
[刷题笔记] Luogu P1466 [USACO2.2] 集合 Subset Sums
[Problem](https://www.luogu.com.cn/problem/P1466) ### Description 有一个长度为$n$的数组为$1-n$,求有多少种选择方案使得选择数之和等于序列和的一半 ### Solution 题面翻译成这样是不是就好做了? 首先,序列和的一半我们 ......
js sum 函数
实现: Array.prototype.Sum = function (fn) { return eval(this.map(x => Number(typeof fn == "function" ? fn(x) : x)).join("+")) || 0 } 用法示例: var arr1 = [{ ......
[LeetCode] 712. Minimum ASCII Delete Sum for Two Strings
Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input: s1 = "sea", s2 = "eat" Out ......
leetcode-n-sum总结
总结一下leetcode中遇见的2-sum, 3-sum, 4-sum问题,并扩展到n-sum。 1. 两数之和 - 力扣(LeetCode) 梦开始的地方,不多说。 class Solution { public int[] twoSum(int[] nums, int target) { Map ......
mysql sum 大量数据查询慢的加速的一种处理方法
有时候查一个月数据,要用到sum来统计,数据大的话,查询起来那一个是慢,可以考虑用联合查询 1.建视图,把一个月要查的分成三段,然后做成一个视图再查 CREATE VIEW B4SUM202302 AS SELECT * FROM (SELECT a,b FROM ( SELECT SUM(B4)A ......
Atcoder ARC060D Digit Sum
看到 $n\le 10^{11}$,考虑按根号分为两部分处理。 对于 $b\le \sqrt{n}$,考虑直接暴力算 $\operatorname{f}(b, n)$ 判断是否等于 $s$,这部分的计算量是 $O(\sqrt{n})$ 级别的。 对于 $\sqrt{n} n$,这个时候 $\oper ......
1775.equal sum arrays with minimum number of operations
Description 1775.equal-sum-arrays-with-minmum-number-of-operations Solution hash table + greedy algorithm The general idea of this problem is hash + g ......
[ARC150F] Constant Sum Subsequence
Problem StatementWe have a sequence of positive integers of length $N^2$, $A=(A_1,\ A_2,\ \dots,\ A_{N^2})$, and a positive integer $S$. For this sequ ......
openpyxl模块---------------------------求和sum
准备数据: 求和代码: import openpyxlwb = openpyxl.load_workbook('C:/Users/Administrator/Desktop/1.xlsx')ws = wb['test']min_row = ws.min_rowmax_row = ws.max_row ......
918. Maximum Sum Circular Subarray (Medium)
Description 918. Maximum Sum Circular Subarray (Medium) Given a circular integer array nums of length n, return the maximum possible sum of a non-empt ......
[LeetCode] 2208. Minimum Operations to Halve Array Sum
You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Not ......
md5sum
md5sum 计算和校验文件报文摘要的工具程序 ## 补充说明 **md5sum命令** 采用MD5报文摘要算法(128位)计算和检查文件的校验和。一般来说,安装了Linux后,就会有md5sum这个工具,直接在命令行终端直接运行。 MD5算法常常被用来验证网络文件传输的完整性,防止文件被人篡改。M ......
ARC125F Tree Degree Subset Sum
感觉挺不错的一道题,不过课上 pb 好像没有讲。 显然树的具体形态对题目影响不大,那么我们知道 $\sum\limits_{i=1}^nd_i=2n-2$ 即可扔掉树的条件。即: > 给定 $n$ 个 $d_i$,和为 $2n-2$,求 $(x,y)$ 满足 $0\le x\le n$ 且 $\ex ......
CF280D k-Maximum Subsequence Sum
大半个月前做的题,现在才写题解,/qd/qd。 贪心,选出 $k$ 个不相交子段的和的最大值,其实相当于每次把序列最大子段拎出来,加上去,然后取相反数。 证明的话可以考虑模拟费用流,$i\le n$,$S\to i$ 连边,$i\to i+1$ 连边,$i\to T$ 连边,边的流量均为 $1$,$ ......
LG4868 Preprefix sum 题解
# 壹、题目大意 给出长度为 $n$ 的序列 $a_1 \sim a_n$,设 $S_i = \sum\limits_{j=1}^i a_j$,有两种操作 可以给定 $i$ 和 $x$,使得 $a_i = x$,也可以给定 $i$,查询 $\sum\limits_{j=1}^i S_j$ 的值 $n ......
ARC163D Sum of SCC
### Description 给定 $N,M$,求对于所有 $N$ 个点的,满足恰有 $M$ 条从小连向大的边,即 $\sum\limits_{(u,v)\in E}[u 给竞赛图每个 SCC (强连通分量)缩点后,剩下的是由一条**极长**的链与某些前向边组成的图。 于是 SCC 的数量能够转换 ......
sha256sum
sha256sum 用于计算文件的 SHA-256 哈希值 ## 补充说明 **sha256sum命令** 是打印或检查 SHA256(256位)校验 ### 语法 ```shell sha256sum [OPTION]... [FILE]... ``` ### 选项 ```shell -b, -- ......
sum
sum 计算文件的校验码和显示块数 ## 补充说明 **sum命令** 用于计算并显示指定文件的校验和与文件所占用的磁盘块数。 ### 语法 ```shell sum(选项)(参数) ``` ### 选项 ```shell -r:使用BSD的校验和算法,块大小为1k; -s:使用system V的校 ......
Atcoder Grand Contest 057 D - Sum Avoidance
先来找些性质: - $A$ 中最小的元素 $M$ 肯定是最小的不是 $S$ 的因子的数,由于 $\text{lcm}(1,2,3,\cdots,43)>10^{18}$,所以 $M\le 43$。 - 对于每个 $0\le iS)break; for(int j=1;j>1; if(calc(mid ......
常用的统计数学函数:sum, sd, mean, cv
```c++ /*********************************************************************** * @file math.h * @ingroup math * @author wangqing * @date 2020-05-14 * ......
[LeetCode] 2461. Maximum Sum of Distinct Subarrays With Length K
You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions: T ......
834. Sum of Distances in Tree (Hard)
Description 834. Sum of Distances in Tree (Hard) There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are g ......
UVA10791 最小公倍数的最小和 Minimum Sum LCM 题解
### 前言 长沙市一中8机房0714模拟测1。 [传送门](https://www.luogu.com.cn/problem/UVA10791) [blog](https://www.luogu.com.cn/blog/JJL0610666/solution-uva10791) # 思路 本题思路 ......
linux 中 md5sum -c选项
001、 [root@PC1 test01]# ls [root@PC1 test01]# seq 5 > a.txt; seq 3 > b.txt ## 生成测试数据 [root@PC1 test01]# ls a.txt b.txt [root@PC1 test01]# md5sum b.txt ......
Atcoder AGC062C Mex of Subset Sum
对 $a_i$ 从小到大进行排序,因为想到若 $ a_{i - 1}$ 肯定是能保证取不到的。 对排完序的 $a_i$ 做一个前缀和 $s_i = \sum\limits_{j = 1}^n$,令 $A_i$ 为 $a_{1\sim i}$ 中无法表示为子序列之和且 $ s_{i - 1} > x$ ......
PAT-甲级-1007 Maximum Subsequence Sum C++
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1≤i≤j≤K. The Maximum S ......
[LeetCode] 931. Minimum Falling Path Sum
Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix. A falling path starts at any element in the first ......
AT_agc062_c [AGC062C] Mex of Subset Sum 思维妙妙题--zhengjun
思路比较巧妙。 首先排序。 考虑目前维护出 $a_{1 \sim i}$ 不能表示的数的集合 $S$。 考虑如何加入 $a_{i+1}$。 如果当前 $sum$ $$S'=S\cup [sum+1,a_{i+1}-1] \cup \{x+a_{i+1}|x\in S\}$$ - 若 $|S\cup ......
Sum in Binary Tree
Sum in Binary Tree time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya really likes mat ......
Maximum Sum
Maximum Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a1,a2 ......