sum

CF1817E Half-sum

`greedy` 把数分成两个集合 $A,B$,且 $A 定理 $1$ > > $A$ 集合合并的顺序一定是从大往小的,$B$ 集合是从小往大的。 应该很好猜到,但是证明需要一点推导。 大概可以局部到 $x,y,z,w$ 四个数的情况。 几种情况分别是 $\frac{x+y}{8}+\frac{z} ......
Half-sum 1817E 1817 Half sum

ARC107F Sum of Abs

# ARC107F Sum of Abs **[题目传送门——洛谷](https://www.luogu.com.cn/problem/AT_arc107_f)** **[题目传送门——AtCoder](https://atcoder.jp/contests/arc107/tasks/arc107_ ......
107F ARC 107 Sum Abs

[LeetCode] 2600. K Items With the Maximum Sum

There is a bag that consists of items, each item has a number 1, 0, or -1 written on it. You are given four non-negative integers numOnes, numZeros, n ......
LeetCode Maximum Items 2600 With

920 F. SUM and REPLACE

[toc] # F. SUM and REPLACE 题目[传送门](https://codeforces.com/contest/920/problem/F) ## 题意: 给你n个数,按照顺序排列,再进行m次操作。每次操作要么是问你区间[l,r]的和,要么是让你将区间[l,r]的所有数$a_i= ......
REPLACE 920 SUM and

[LeetCode] 2679. Sum in a Matrix

You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty: From eac ......
LeetCode Matrix 2679 Sum in

elasticsearch group sum top 10

``` { "version": true, "size": 0, "sort": [ { "request_length": { "order": "desc", "unmapped_type": "boolean" } } ], "stored_fields": [ "*" ], "script ......
elasticsearch group sum top 10

AtCoder Regular Contest 163 D Sum of SCC

[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc163_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc163/tasks/arc163_d "AtCoder 传送门") 怎么连这种相对传统 ......
AtCoder Regular Contest 163 Sum

【每日一题】Problem 489C. Given Length and Sum of Digits...

[原题](https://codeforces.com/problemset/problem/489/C) #### 解决思路 结果值越大,要求满足后续数位能成立的情况下,当前数位的值尽可能大;取最小结果同理 ##### 误区 1. 注意边界 - 一般情况下,数字开头不能为 0,除非数字长度为 ** ......
Problem Digits Length Given 489

Codeforces 1458F - Range Diameter Sum

先考虑直径的一些求法:最普遍的想法肯定是从点集中任意一个点开始 DFS 找到距其最远的点,再一遍 DFS 找到距离你找到的那个点最远的点。但是放在这个题肯定是不太行的。因此考虑一种更常用的求法:**合并**。更直观地说:我们定义树上一个圆 $(x,r)$ 表示距离 $x$ 点 $\le r$ 的所有 ......
Codeforces Diameter 1458F Range 1458

[LeetCode] 1186. Maximum Subarray Sum with One Deletion

Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, y ......
LeetCode Deletion Subarray Maximum 1186

Subset Sum 问题单个物品重量限制前提下的更优算法

## 前言 看了 [ShanLunjiaJian 关于这个问题的文章](https://www.luogu.com.cn/blog/uakioi/nv-knapsack),是完全没看懂,沙东队爷的中枢神经内核配置把我偏序了。叉姐在下面提了个论文,论文找不到资源,谁搞到了可以 Q 我一份之类的拜谢了。 ......
单个 算法 重量 前提 物品

stata gen egen sum不同功能

clear input x 1 2 3 4 end gen sx_gen = sum(x) egen sx_egen = sum(x) list , clean noobs //gen 提供的 sum() 函数执行的是「累积加总」,而 egen 提供的 sum() 函数则进行「整体加总」 ......
功能 stata egen gen sum

每日一题力扣 1262 https://leetcode.cn/problems/greatest-sum-divisible-by-three/

、 题解 这道题目核心就算是要知道如果x%3=2的话,应该要去拿%3=1的数字,这样子才能满足%3=0 贪心 sum不够%3的时候,就减去余数为1的或者余数为2的 需要注意 两个余数为1会变成余数为2的,所以可能减去2个余数为1 核心代码如下 public int maxSumDivThreeOth ......

[LeetCode] 1262. Greatest Sum Divisible by Three

Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three. Example 1: Input: nums = [3, ......
Divisible LeetCode Greatest Three 1262

[ABC282Ex] Min + Sum

[ABC282Ex] Min + Sum 一道分治题。比较新的地方在于,别的题都是按中点为M分治,而这道题是按最小值为M分治。记录b的前缀和sum。【L,R】最小值为M,则分为【L,M-1】,【M+1,R】。 #include<bits/stdc++.h> using namespace std; ......
ABC 282 Min Sum Ex

CF1817E Half-sum 另解与 Trygub Number

一题水两篇怎么说。 上一篇中我们采用智慧方法减少了比较次数,避免了使用复杂的高精度数。现在我们有高论!可以做到 $\mathrm O(\log_B V\log_2 n)$ 在某一位加或者减一个大小 $\mathrm O(V)$ 的数,支持判断正负和取特定位的值。怎么做呢。很简单,我们每一位的数值域原 ......
Half-sum Trygub Number 1817E 1817

CF1817E Half-sum

## 题意 有一个大小为 $N$ 的非负整数集合 $A$,每次你可以从集合中取任意两个数,并将它们的平均数放回序列。不停操作,知道集合最后剩下两个数。请求出这两个数的差的绝对值的最大值对 $10^9+7$ 取模的结果。 数据范围:$1\le N\le 10^6, 0\le A_i\le 10^9$。 ......
Half-sum 1817E 1817 Half sum

Leetcode Hot 100 & 560. Subarray Sum Equals K

参考资料: 考点:子串 & [题干] 1 Input: nums = [1,1,1], k = 2 2 Output: 2 这道题说实话看得我一脸懵,第一时间想到的自然是双层循环遍历的一个$O(n^2)$的解法,也就是官方的解法一。但是使用这种解法会超时(Python语言是这样的,评论区有人提到了) ......
Leetcode Subarray Equals Hot 100

AtCoder Beginner Contest 298 Ex Sum of Min of Length

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc298_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc298/tasks/abc298_h "AtCoder 传送门") 挺无脑的。是不是因 ......
Beginner AtCoder Contest Length of

[ABC162E] Sum of gcd of Tuples (Hard)

## 题面翻译 给定$n,k$,求 $$\sum^k_{a_1=1}\sum^k_{a_2=1}\sum^k_{a_3=1}\dots\sum^k_{a_n=1}gcd(a_1,a_2,a_3,\dots,a_n)\ mod\ 1000000007$$ ### 制約 - $ 2\ \leq\ N\ ......
Tuples 162E Hard of ABC

从 sum 求和谈 axis=1 or 0

## 二维数组 `axis=0`:表示从上往下 `axis=1`:表示从左往右 ![](https://img2023.cnblogs.com/blog/2584038/202306/2584038-20230610193731678-476806344.jpg) ```python temp = ......
axis sum or

【每日一题】Problem 1832B - Maximum Sum

[原题](https://codeforces.com/problemset/problem/1832/B) #### 解决思路: 类似滑动窗口的方式,窗口大小为 k 次操作,从中找到更大的结果即可 #### 误区: 一开始的想法是每次都在前一次的基础上减去最少的,然而在样例的第五个测试点出错,因为 ......
Problem Maximum 1832B 1832 Sum

Sum of MSLCM 题解

[Sum of MSLCM](https://www.luogu.com.cn/problem/UVA1730) ### 题目大意 定义 $\text{MSLCM}(n)$ 为所有满足该数集的 $\text{lcm}$ 为 $n$ 的数集中元素个数最多的数集的所有数字的和,现有多次询问,求 $$\s ......
题解 MSLCM Sum of

AtCoder Regular Contest 153 D Sum of Sum of Digits

[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc153_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc153/tasks/arc153_d "AtCoder 传送门") 又浪费一道好题![ ......
Sum AtCoder Regular Contest Digits

AtCoder Beginner Contest 267 Ex Odd Sum

[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc267_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc267/tasks/abc267_h "AtCoder 传送门") 直接暴力跑背包的复 ......
Beginner AtCoder Contest 267 Odd

CF1442D Sum

## 题意 有 $n$ 个不降的非负整数数组,每个数组可以不取或取一个前缀,总共要取 $k$ 个元素,问取到的和最大多少。 ## 题解 结论题,但是想到结论还不会。 首先,我们只会有一个数组没选完,其它要么全选要么不选。证明考虑假设两个数组都没选完,基于数组单调不降进行一些分类讨论会发现存在一些严格 ......
1442D 1442 Sum CF

AtCoder Regular Contest 130 C Digit Sum Minimization

[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc130_c "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc130/tasks/arc130_c "AtCoder 传送门") 分类讨论,但是写起 ......
Minimization AtCoder Regular Contest Digit

「USACO2016JAN」Subsequences Summing to Sevens

[USACO16JAN]Subsequences Summing to Sevens S 题目描述 Farmer John's $N$ cows are standing in a row, as they have a tendency to do from time to time. Each ......
Subsequences Summing Sevens USACO 2016

POJ2739 Sum of Consecutive Prime Numbers&&Acwing4938 连续质数之和

方法:单调队列 为什么是单调队列?因为这里让我们求连续的质数和,我们可以利用欧拉筛来维护质数,再利用单调队列来维护连续的质数。 代码( ~~POJ 不支持 C++ 11 差评~~): #include<cstdlib> #include<cstring> #include<cstdio> #incl ......
质数 之和 Consecutive amp Numbers