second 140e abc sum
sum
sum 计算文件的校验码和显示块数 ## 补充说明 **sum命令** 用于计算并显示指定文件的校验和与文件所占用的磁盘块数。 ### 语法 ```shell sum(选项)(参数) ``` ### 选项 ```shell -r:使用BSD的校验和算法,块大小为1k; -s:使用system V的校 ......
AT_abc258_g 题解
[题目链接](https://www.luogu.com.cn/problem/AT_abc258_g) ### 题意简述 给定一张无向图,若图中三个点 $a$,$b$,$c$ 满足 $a$ 与 $b$ 有边相连,$a$ 与 $c$ 有边相连,$b$ 与 $c$ 有边相连,则称点 $a$,$b$,$ ......
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 ......
随笔(二十五)『3个线程交替输出1-100、交替输出ABC』
#### 1、3个线程交替输出1-100 ``` /** * 需求: * 3个线程交替输出1-100 */ public class TestPrint1_100 { private Integer state = 1; // 状态值1-t1执行, 2-t2执行, 3-t3执行 private In ......
常用的统计数学函数: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 ......
ABC307
## T1:[Weekly Records](https://atcoder.jp/contests/abc307/tasks/abc307_a "Weekly Records") 模拟 代码实现 ``` n = int(input()) a = list(map(int, input().spli ......
ABC-303-B-Discord
Time Limit: 2 sec / Memory Limit: 1024 MB Score : 200200 points Problem Statement N people numbered 1,2,…,�1,2,…,N were in �M photos. In each of the p ......
[ABC310D] Peaceful Teams 题解
[Peaceful Teams](https://www.luogu.com.cn/problem/AT_abc310_d) ### 题目大意 将 $n$ 个人分成 $T$ 组,要求每组不能包含敌对的人,问有多少种分法。 ### 思路分析 注意到 $n,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 ......
ABC286
[[ABC286C] Rotate and Palindrome](https://www.luogu.com.cn/problem/AT_abc286_c) 容易发现两种操作互不干扰,所以考虑枚举换位操作个数,再计算出相应的替换操作个数,最后取最小值即可。 复杂度 $O(n^2)$。 [[ABC2 ......
ABC285
[[ABC285D] Change Usernames](https://www.luogu.com.cn/problem/AT_abc285_d) 依据题意直接连边,判断有没有环即可。 复杂度 $O(n)$ [[ABC285E] Work or Rest](https://www.luogu.co ......
ABC284
[[ABC284D] Happy New Year 2023](https://www.luogu.com.cn/problem/AT_abc284_d) 暴力肯定不行,尝试简单讨论一下。 1. 如果 $q > \sqrt n$,那么 $p^2 \sqrt n$,那么 $p < \sqrt n$,因 ......
题解 [ABC276F] Double Chance
很容易想到分类。 我们可以把 $1$ 到 $i-1$ 的球分为两类,一类是权值小于 $val_i$,另一类是权值大于 $val_i$。 对于第一类,$sum$ 加上小于 $val_i$ 的球的个数乘以 $val_i$。 对于第二类,$sum$ 加上所有大于 $val_i$ 的球的权值。 这显然可以用 ......
UVA10791 最小公倍数的最小和 Minimum Sum LCM 题解
### 前言 长沙市一中8机房0714模拟测1。 [传送门](https://www.luogu.com.cn/problem/UVA10791) [blog](https://www.luogu.com.cn/blog/JJL0610666/solution-uva10791) # 思路 本题思路 ......
ABC310
## T1:[Order Something Else](https://atcoder.jp/contests/abc310/tasks/abc310_a) 模拟 代码实现 ``` n, p, q = map(int, input().split()) d = list(map(int, inpu ......
ABC抽象类笔记
python抽象类的介绍 python的abc模块提供了对抽象类的支持,通过继承ABC类,可以实现定义一个抽象父类,这个父类可以提前定义好一些抽象接口,可以通过继承抽象父类并实现这些接口方法来定义不同的类 比如我们定义一个图形类 from abc import ABC, abstractmethod ......
[AtCoder ABC302] F - Merge Set
Problem Statement If we add edges between every pair of sets that have shared elements, there will be O(N^2) edges to traverse. Instead, we can add N ......
abc310f <dp + bitmask>
### 题目 [F - Make 10 Again](https://atcoder.jp/contests/abc310/tasks/abc310_f) ### 思路 [参考](https://www.cnblogs.com/legendstane/p/freee-programming-cont ......
abc310e <公式递推(dp?)>
### 题目 [E - NAND repeatedly](https://atcoder.jp/contests/abc310/tasks/abc310_e) ### 思路 ![image](https://img2023.cnblogs.com/blog/3165412/202307/316541 ......
abc310d <dfs暴搜-分组方案数 / bitmask表示集合+dp>
### 题目 [D - Peaceful Teams](https://atcoder.jp/contests/abc310/tasks/abc310_d) **参考:** https://www.cnblogs.com/legendstane/p/freee-programming-contest ......
[abc309 G] Ban Permutation
### [G - Ban Permutation](https://atcoder.jp/contests/abc309/tasks/abc309_g) 首先看到绝对值,很烦,考虑取掉绝对值得到$p_i\leq i-X$或$p_i\geq i+X$ 然后我们就自然而然有了一个暴力的想法,设$dp[i ......
[abc309 F] Box in Box
# [F - Box in Box](https://atcoder.jp/contests/abc309/tasks/abc309_f) 首先,每个长方体的$h,w,d$都是可以任意互换的,所以我们考虑用$a_0,a_1,a_2$来代替它们($a_0\leq a_1\leq a_2$) 然后可以发 ......
ABC310
[**A**](https://atcoder.jp/contests/abc310/tasks/abc310_a) ## 题意 给你$n,p,q$ 给你一个$n$长度的数组$D$ ,返回$\min(D_i+q,p)$ ~~~C++ #include using namespace std; typ ......
[ABC310E] NAND repeatedly 题解
怎么都是 dp 做的,就我是手玩出来的吗/oh。 首先关于 $\operatorname{NAND}$ 有一个经典技巧:$x\barwedge 0=1,x\barwedge 1=\neg x$。 发现一个 $0$ 会将值强制置 $1$,而一个 $1$ 会将值取反,于是 $f(l,r)$ 的值只取决于 ......
[ABC310F]Make 10 Again
[[ABC310F]Make 10 Again](https://atcoder.jp/contests/abc310/tasks/abc310_f) ## 题意 给定 $N$ 个骰子,每个骰子会随机的出现数字 $1$ 到 $A_i$ , 求能够从 $N$ 个骰子中选若干个, 使他们的点数之和为 $ ......
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 ......
ABC243F
发现直接记录有哪些奖品被选是不可能的,所以考虑转换一下思路:设 $dp_{i,j,p}$ 为只考虑前 $i$ 个奖品,抽了 $j$ 次,有 $p$ 种不同奖品的的概率。 这个状态相当于是维护一个操作(抽奖)序列。考虑每次加入 $q$ 个第 $i$ 种奖品,就相当于是将原序列和一个由 $q$ 个 $i ......
abc089 <前缀和>
### 题目 [D - Practical Skill Test](https://atcoder.jp/contests/abc089/tasks/abc089_d) ### 思路 - 计算出所有结点在跳转过程中的前缀和, 从而O1查询 - 根据数据范围, 实际上不需要二分, 直接开相同大小的数组 ......