设计模式之原型模式 Intro 简介 原型模式,用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象 原型模式其实就是从一个对象再创建另外一个可定制的对象而且不需要知道任何创建的细节。 实现方式 实现方式大致如下: 在 c# 中可以借助 ICloneable 接口和 MemberwiseC ...
分类:
其他好文 时间:
2020-07-18 00:41:48
阅读次数:
76
题目链接 题目大意:给出一颗含有$n$个结点的树,每个节点有一个颜色。求树中每个子树最多的颜色的编号和。 树上启发式合并(dsu on tree)。 我们先考虑暴力怎么做。遍历整颗树,暴力枚举子树然后用桶维护颜色个数。这样做是$O(n^2)$的,显然会T。我们需要一种更快的算法:树上启发式合并。 关 ...
分类:
其他好文 时间:
2020-07-17 22:21:39
阅读次数:
58
https://codeforces.com/problemset/problem/489/C C. Given Length and Sum of Digits... You have a positive integer m and a non-negative integer s. Your ...
分类:
其他好文 时间:
2020-07-17 22:18:10
阅读次数:
71
先引出偏函数 #一个带有可变参数的sum函数 def sum(*args): s=0 for i in args: s=s+n return s #想要输出(sum(10,20)+sum(1,2,3,4,5)) print(sum(10,20)+sum(1,2,3,4,5)) 这样虽然通俗易懂,但是 ...
分类:
编程语言 时间:
2020-07-17 22:06:21
阅读次数:
83
压测设置 线程数:并发数量,能跑多少量。具体说是一次存在多少用户同时访问 Rame-Up Period(in seconds):表示在多长时间内启动完上述的线程数。 循环次数:这个设置不会改变并发数,可以延长并发时间。总请求数=线程数*循环次数 调度器:设置压测的启动时间、结束时间、持续时间和启动延 ...
分类:
其他好文 时间:
2020-07-17 19:44:02
阅读次数:
87
题意:有一$n$个点,$m$条边的双向图,每条边都有花费和流量,求从$1$~$n$的路径中,求$max\frac{min(f)}{\sum c}$. 题解:对于c,一定是单源最短路,我们可以用dijkstra,但是这个最小流量不是很好搞,但是题目所给的数据范围较小,所以我们可以直接枚举最小流量,然后 ...
分类:
其他好文 时间:
2020-07-17 19:42:27
阅读次数:
70
How to Create Multiple lists from CSV File? We can use the combination of CSV and PowerShell to create multiple lists in bulk in SharePoint Online. He ...
分类:
系统相关 时间:
2020-07-17 14:13:50
阅读次数:
83
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n ...
分类:
其他好文 时间:
2020-07-17 13:33:50
阅读次数:
46
本题考察的是回溯算法,可以使用DFS解决问题。 C++版本 #include <iostream> #include <vector> using namespace std; int getDigitSum(int num){ int sum = 0; while(num > 0){ sum += ...
分类:
其他好文 时间:
2020-07-17 11:28:13
阅读次数:
48
7.15 dp专题 T1.sum 小Z爱求和 https://www.luogu.com.cn/problem/T138967 无脑暴力骗20... 正解 n2 个元素,挨个统计是 O( n2 ) ,所以统计每个点的贡献 复杂度降到O(n) 对于每个点,他可能贡献的区间是 L= pre(k-1) 前 ...
分类:
其他好文 时间:
2020-07-16 21:46:57
阅读次数:
58