sum

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 ......
and 979D Kuro 979 GCD

001_two_sum

准备工作 安装vscode(并安装其leetcode插件)、nodejs环境。 问题描述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答 ......
two_sum 001 two sum

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 ......
Leetcode 4sum 454 sum II

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 ......
D-Sum 1442 Sum CF

[AGC030D] Inversion Sum

### 题目大意 一个长度为 $n$ 的数列,然后给你 $q$ 个交换或不交换操作,你可以选择操作或者不操作,问所有情况下逆序对的总和。 答案需要对 $10 ^ 9 + 7$ 取模。 ($n\leq 3000$,$q\leq 3000$)。 ### 思路 这道题非常巧妙。 我们先考虑转化题意,求逆序 ......
Inversion 030D AGC 030 Sum

[AGC030D] Inversion Sum 题解

## 题意 给定一个长度为 $n$ 的排列 $a$ 和 $m$ 个形如 $\left(x,y\right)$ 的操作,每次操作可以选择是否交换 $a_x, a_y$,求最终所有形成的排列的逆序对总数。 ($1 \le n,m \le 3000$)。 ## 题解 考虑转化题意,考虑求出最终总的期望逆序 ......
题解 Inversion 030D AGC 030

[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 ......

Leetcode 1. 两数之和(Two sum)

[题目链接🔗](https://leetcode.cn/problems/two-sum) 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素 ......
之和 Leetcode Two sum

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+ ......
Subset P1466 1466 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 ......
条件 方法 MySQL SUM

js 计算对象数组中某个字段sum之和

1、一个字段之和 要计算一个对象数组中某个字段的和,你可以使用 JavaScript 的 Array.prototype.reduce() 方法。reduce() 方法对数组中的每个元素执行一个提供的函数,并将结果累积为单个值。以下是一个示例: 假设你有一个对象数组 data,每个对象都有一个 va ......
之和 数组 字段 对象 sum

[ABC238E]Rcange Sums

## 前言 一道水得不能再水的题,虽说在图论的题单里,但我真的没有用图,用了并查集就轻松$AC$。 ## 大意 输入$q$个$l,r$,表示知道$l$到$r$的区间,最后问能不能知道$0$到$n$,能就输出`Yes`,不能就输出`No`。 ## 思路 1. 图论做法:可以把知道$l$到$r$的区间抽 ......
Rcange 238E Sums ABC 238

[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 ......
题解 098D ABC 098 Xor

[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 ......
Subset 056D Game AGC 056

CF1762E Tree Sum 题解

## 题意 对于一棵 $n$ 个节点的树 $T$,定义 $\operatorname{good}(T)$ 为真当且仅当边权 $w \in \left\{-1,1\right\}$ 且对于任意节点 $u$,均有 $\displaystyle f(u) = \prod\limits_{\left(u, ......
题解 1762E 1762 Tree Sum

使用MD5算法和sha512sum校验和检验文件完整性

[TOC] # 一.前言 在我们日常生活中,无论是下载文件、传输数据还是备份重要信息,如何确保数据的完整性始终是一个不能忽视的问题。本文将向大家介绍如何使用MD5算法和sha512sum校验和来进行文件完整性的验证。 # 二.MD5算法简介 MD5算法,全称Message-Digest Algori ......
算法 完整性 文件 MD5 512

[口胡记录] AGC020C Median Sum

([题目传送门](https://www.luogu.com.cn/problem/AT_agc020_c)) 一开始口胡结论,发现假了…… 把所有的子集和放到数轴上,惊奇地发现它们关于 $\dfrac{sum}{2}$ 对称,于是做一遍存在性背包,从 $\dfrac{sum}{2}$ 开始找第一个 ......
Median 020C AGC 020 Sum

[LeetCode][64]minimum-path-sum

# Content Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along ......
minimum-path-sum LeetCode minimum path sum

CF276C Little Girl and Maximum Sum 题解

[题目链接](https://www.luogu.com.cn/problem/CF276C) ## 题目大意 通过修改序列 $a$ 中的数的顺序,使 $$ \sum_{i=1}^q\sum_{j=l}^ra[j] $$ 最大,并输出它的值。 ## 思路 一道简单贪心 $+$ 差分,通过差分的优秀的 ......
题解 Maximum Little 276C Girl

CF847C Sum of Nestings 题解

[题目链接](https://www.luogu.com.cn/problem/CF847C) ## 思路 一道简单的**递归**题,题目要求我们构建一个有 $n$ 对括号且有 $k$ 对嵌套的括号序列(一对嵌套表示的是两对对应的括号一个被另一个包含)。如果无法构建满足条件的括号序列,则输出 Imp ......
题解 Nestings 847C 847 Sum

【leetcode】1.two sum

第一题给我干懵了...想达到这个要求把我脑壳都想痛了...Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity? 一开始想过用map,但是不能解决重复key的问题。 然而我用sort, ......
leetcode two sum

Cogito, ergo sum

, sed mi ne volas pensi. I write this article because my deskmate is writing. But apparently it's far simpler :) 为什么这个会渲染 `:)` 啊???:smile: 1. $\dbinom ......
Cogito ergo sum

【题解】[ARC158C] All Pair Digit Sums

[传送门](https://www.luogu.com.cn/problem/AT_arc158_c) ## 题目分析 我们可以先从简单一点的情况开始分析,如果现在 $a_{[i]},a_{[j]}$ 都**不会进位**,那么最后的 $f(a_{[i]}+a_{[j]})=f(a_{[i]})+f( ......
题解 Digit 158C Pair Sums

Leetcode 209. 长度最小的子数组(Minimum size subarray sum)

[题目链接](https://leetcode.cn/problems/minimum-size-subarray-sum) 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl+1, ..., ......
数组 长度 Leetcode subarray Minimum

Max Mobius Sum

[Link](https://codeforces.com/gym/104455/problem/E) 不妨记 $A = a_1,a_2,\dots,a_n$ 和 $B = a_{n+1},a_{n+2},\dots,a_{2n}$ 考虑“交换”对 $A$ 和 $B$ 的影响,会发现它们都变成了环形 ......
Mobius Max Sum

LCM Sum[数论+树状数组]

Problem - E2 - Codeforces 给一个区间[L,R],询问有多少三元组(i,j,k)满足L=<i<j<k<=r且lcm(i,j,k)>=i+j+k. 正难则反。我们可以考虑它的补集。 lcm<i+j+k,然后是i+j+k<3*k 所以lcm<3k,又因为k是lcm的因数,所以lc ......
数论 数组 LCM Sum

LeetCode 16. 3Sum Closest 双指针+排序

Given an integer array `nums` of length n and an integer `target`, find three integers in nums such that the sum is closest to `target`. Return the su ......
指针 LeetCode Closest 3Sum Sum

Calculate floor sum

[problem](https://atcoder.jp/contests/practice2/tasks/practice2_c) 不用 ACL! ```cpp ll fs(ll n,ll m,ll a,ll b){ ll res=0; if (a>=m){ res+=n*(n+1)/2*(a/m ......
Calculate floor sum

mysql sum()按条件求和、count()按条件计数

建议看:https://www.cnblogs.com/Marydon20170307/p/15913081.html 相关题目:[各个视频的平均完播率\_牛客题霸\_牛客网](https://www.nowcoder.com/practice/96263162f69a48df9d84a93c710 ......
条件 mysql count sum

AGC030D. Inversion Sum

双倍经验:[CF258D. Little Elephant and Broken Sorting](https://codeforces.com/problemset/problem/258/D) 好巧妙,想不到。 因为 $n$ 并不大,且直接统计显然很困难,考虑数对 $(i,j),ia_j$。 更 ......
Inversion AGC 030 Sum