sum

[ARC117E] Zero-Sum Ranges 2题解

题解 前言 个人认为官方题解写得最为详细、干净、清楚,如果有意向阅读外文版的题解的话,还是推荐去读一读: Editorial - AtCoder Regular Contest 117 本文属于转载(?),有一些自己的思考过程,希望有帮助。 题意 有多少个长度为 \(2N\) 的序列 \(A\) 满 ......
题解 Zero-Sum Ranges 117E Zero

[LeetCode] 2824. Count Pairs Whose Sum is Less than Target

Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j] < ......
LeetCode Target Count Pairs Whose

MySQL中count()、sum()区别

1、count0函数 里面的参数是列名的的时候,会计算有值项的次数sum(函数 里面的参数是列名的时候,会计算 列名的值的和。2、两个函数在 记录的列名的值为空或者是null时,都不会去统计即count(列名)和sum(列名) 都不计入这条记录 3、count()可以计算出行数,count (1)也 ......
MySQL count sum

DPS Digit Sum

题意 求 \(1 \to n\) 中有多少个数是 \(d\) 的倍数。 \(n \le 10 ^ {10000}\)。 Sol 数位 dp,设 \(f_{i, j, 1 / 0}\) 表示第 \(i\) 位,膜 \(d\) 等于 \(j\),是否贴住上限。 转移是 \(trivial\) 的。 Co ......
Digit DPS Sum

09-基础SQL-DQL(数据查询语言)-聚合函数(count、max、min、avg、sum)

DQL-介绍(常用) DQL英文全称是Data Query Language(数据查询语言),数据查询语言用来查询数据库中表的记录 查询关键字:SELECT DQL-语法 ......
函数 数据查询 SQL-DQL 语言 基础

【题解 CF1628D2】 Game on Sum

Game on Sum (Hard Version) 题面翻译 Alice 和 Bob 正在玩一个游戏,游戏分为 \(n\) 个回合,Alice 和 Bob 要轮流对一个数 \(x\) 进行操作,已知这个数初始值是 \(0\)。 具体每个回合的行动规则如下: Alice 选择一个在区间 \([0,k ......
题解 1628D 1628 Game Sum

How to use SUM and DINSTINCT with GreenDao?

How to use SUM and DINSTINCT with GreenDao querybuilder? Ask Question Asked 7 years ago Modified 6 years, 7 months ago Viewed 1k times Part of Mobile ......
DINSTINCT GreenDao with How SUM

[ARC107F] Sum of Abs 题解

题意 给定一个 \(N\) 个点,\(M\) 条边的简单无向图,每个节点有两个值 \(A_i\) 和 \(B_i\)。 现对于每个节点,均可以选择花费 \(A_i\) 的代价将其删去或保留节点。若一个节点被删除,那么所有与其向连的边也会被删除。 定义一个极大联通块的权值为联通块内所有节点的 \(B_ ......
题解 107F ARC 107 Sum

[USACO23FEB] Equal Sum Subarrays G 题解

[USACO23FEB] Equal Sum Subarrays G 题解 题目链接 \(O(n^5)\) 暴力 显然,如果修改 \(a_i\) 的值,只会影响包含 \(a_i\) 的区间的区间和。于是对于每个 \(a_i\),可以将所有区间分成两类,即包含 \(a_i\) 的区间和不包含 \(a_ ......
题解 Subarrays USACO Equal FEB

[题解] ABC282Ex Min + Sum

Min + Sum 给你两个序列 \(a\)、\(b\) 和 \(S\),求满足一下条件的区间 \([l ,r]\) 的数量: \(\sum_{i = l}^r b_i + \min_{i = l}^r a_i \le S\)。 \(n \le 2 \times 10^5\)。 考虑按最小值分治,即 ......
题解 ABC 282 Min Sum

CF1485F Copy or Prefix Sum 题解

思路 考虑 \(a_i\) 要么是 \(b_i\) 要么是 \(b_i - s\)。 考虑 \(s\) 代表着什么。 它是 \(a\) 的前缀和。 那么必然是往前一段 \(b\) 的和。 因为每个 \(b\) 代表着要么是这一位的 \(a\) 或者前面所有的 \(a\)。 考虑设 \(f_i\) 为 ......
题解 Prefix 1485F 1485 Copy

P9821 [ICPC2020 Shanghai R] Sum of Log

原题链接 题意,求: \[\sum_{i=0}^{X}\sum_{j=[i=0]}^{Y}[i\&j=0]\lfloor\log_2(i+j)+1\rfloor \]为简洁,记 \(\lg(x)=\lfloor\log_2(x)\rfloor,n=\max(X,Y)\) 由于 \(i\&j=0\) ......
Shanghai P9821 9821 2020 ICPC

P1466 [USACO2.2] 集合 Subset Sums

P1466 USACO2.2 集合 Subset Sums 毫无思路 如果不告诉我这题是DP题,我一定会爆搜。 看了题解,很妙。 居然也能套背包板子。 定义F[i][j]为在前\(i\)个数中选择一些数其和为\(j\)的方案总数。 显然转移方程F[i][j] = F[i - 1][j] + F[i ......
USACO2 Subset P1466 USACO 1466

debian 11 安装docker-ce 出现异常 “Hash Sum mismatch Hashes of expected file”

最近接手一个新的项目,需要在内网布置一套新系统,有docker 版本的要求,原来的docker 版本过低需要进行升级,按部就班的升级docker如下 安装 # 这里是用的debian 11 # 如果安装过docker apt-get remove docker docker-engine docke ......
docker-ce mismatch expected debian Hashes

题解 [ARC149B] Two LIS Sum

题解 [ARC149B] Two LIS Sum 大胆猜结论,按照 \(a\) 数组为关键字进行排序,求更改后 \(b\) 的 \(LIS\) 。 证明:每次移动,都有 \(a\) 中增加一个长度, \(b\) 中贡献可能为 \(\{-1,0,1\}\) , 总体贡献为 \(\{0,1,2\}\) ......
题解 149B ARC 149 Two

[LeetCode] 2574. Left and Right Sum Differences

Given a 0-indexed integer array nums, find a 0-indexed integer array answer where: answer.length == nums.length. answer[i] = |leftSum[i] - rightSum[i] ......
Differences LeetCode Right 2574 Left

PAT_A1081 Rational Sum

1、 #分数 本题主要考察分数的运算,和分数的输出 2、数据范围为int,但两分母相乘时,最大可达到long long,应该用long long 3、测试点4会检查0的输出。 ......
Rational PAT_A 1081 PAT Sum

PAT_A1104 Sum of Number Segments

Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we ......
Segments Number PAT_A 1104 PAT

003Square(n)Sum(8kyu)from codewars

Square(n)Sum Complete the square sum function so that it squares each number passed into it and then sums the results together. 完成平方和函数,对每个传入其中的数字平方并相 ......
codewars Square 8kyu from 003

Leecode 1. 两数之和 Two Sum

给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 1: 输入:nums = [2,7, ......
之和 Leecode Two Sum

PAT 甲级【1007 Maximum Subsequence Sum】

本题是考察动态规划与java的快速输入: max[i]表示第i个结尾的最大的连续子串和。b begin[i]表示第[begin[i],i]为最大和的开始位置 超时代码: import java.io.BufferedReader; import java.io.IOException; import ......
甲级 Subsequence Maximum 1007 PAT

【dp】【竞赛图的性质】ARC163D Sum of SCC 题解

ARC163D 发现这个竞赛图一定能被分为两个集合 \(A\),\(B\)。满足 \(\forall u\in A,v\in B\),均有 \(u\to v\in E\)。答案就是划分这两个集合的方案数。 证明: 首先,竞赛图缩完点后一定是一条链,对强连通分量进行标号,满足编号小的强连通分量指向编号 ......
题解 性质 163D ARC 163

linux 中 md5sum -c 命令

001\ [root@pc1 test01]# ls [root@pc1 test01]# seq 3 > a.txt ## 测试文件 [root@pc1 test01]# ls a.txt [root@pc1 test01]# cat a.txt 1 2 3 [root@pc1 test01]# ......
命令 md5sum linux 5sum md5

Count of Sub-Multisets With Bounded Sum

Count of Sub-Multisets With Bounded Sum You are given a 0-indexed array nums of non-negative integers, and two integers l and r. Return the count of s ......
Sub-Multisets Multisets Bounded Count With

CF1628D2 Game on Sum

题目链接(Easy) 题目链接(Hard) Part1 神奇的博弈类型 \(Dp\) 。 我们发现与当前状态有关的量,有且只有 现在是第几轮,还有 Bob 用了几次加的操作 ,这都会影响之后的决策,而和之前的决策无关,换句话说,当前决策有后效性,没有前效性。那我们考虑倒着 \(Dp\). Part2 ......
1628D 1628 Game Sum CF

[LeetCode] 1354. Construct Target Array With Multiple Sums 多次求和构造目标数组

You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure : let x be the sum ......
数组 Construct LeetCode Multiple 目标

Codeforces Round 684 (Div. 2) B. Sum of Medians

定义 \(median\) 是一个非降序数组中第 \(\lceil \frac{n}{2} \rceil\) 的数。数组从 \(1\) 开始标号。 给两个数 \(n\) 和 \(k\) ,并给出一个长为 \(nk\) 的数组 \(a\) 。 需要分出为 \(k\) 个大小为 \(n\) 的数组,每个 ......
Codeforces Medians Round 684 Div

解决SUM函数返回为NULL

解决SUM函数返回为NULL SUM函数的作用:计算某一字段中所有行的数值和, 使用SUM函数进行对符合条件的结果行数进行求和。 问题产生: sum 求和时会对 null 进行过滤,不计算,但如果没有返回结果,则sum 函数的返回值为 null,不是 0: 解决方式: 1. IFNULL 使用IFN ......
函数 NULL SUM

CF1886A Sum of Three 题解

Question 给定一个正整数 N ,我们需要找三个不同的整数x,y,z,使得 N = x+y+z,其中下x,y,z不能被三整除 solution 我们把N%3会有一些余数,我们针对余数来讨论,其中我们只关注xyz的余数 如果余数为0 那么也就可能是1+1+1,或者2+2+2,但是考虑到xyz不同 ......
题解 1886A Three 1886 Sum

Codeforces Round 891 (Div. 3) F. Sum and Product(数论+map)

Codeforces Round 891 (Div. 3) F. Sum and Product 思路:对于x,y:ai+aj=x —> aj=x-ai 因此 ai*(x-ai) = y ——> ai = (x 土 sqr( x^2 - 4y ) ) /2 对应的 ai 就是要的两个值 若两个值不同 ......
数论 Codeforces Product Round 891