1th 两数之和 暴力枚举法 直接两重循环暴力枚举,很慢。 class Solution { public int[] twoSum(int[] nums, int target) { int[] ans = new int[2]; for(int i = 0; i < nums.length; i ...
分类:
其他好文 时间:
2020-07-04 14:59:09
阅读次数:
48
namespace EnumDemo { class Program { static void Main(string[] args) { var name = enumValue.first.ToString(); Console.WriteLine($"输出第一个描述值:{ name }"); ...
分类:
其他好文 时间:
2020-07-04 11:56:07
阅读次数:
55
The Suspects 题目:编号为0的人有传染病,同组中只要有一个人有传染病,该组的人都被看做有传染病,一个人可以在多组中,问有多少人有传染病。 思路:并查集,需要压缩并查集的树,编号小的点优先作为祖先(0为root),并查集过程中传递祖先的同时传递祖先是否是病人,最后再次遍历所有人,使得祖先是 ...
分类:
其他好文 时间:
2020-07-04 01:20:05
阅读次数:
57
1.loj[6181]某个套路求和题 题意: 从前有个 alpha1022,他在看某本奇妙的书的时候想到了这样一个函数: 然后就有了这样一个问题: 解体思路: 观察发现,$f(i)$的值只有3种:0,-1,1。所以我们可以枚举不同值的方案数来得到答案。 首先考虑最好想的情况:值为0。易证当仅当一个数 ...
分类:
其他好文 时间:
2020-07-03 21:52:51
阅读次数:
87
public class Test { public static void main(String args[]){ Test tester = new Test(); // 类型声明 MathOperation addition = (int a, int b) -> a + b; // 不用类 ...
分类:
编程语言 时间:
2020-07-03 21:50:39
阅读次数:
85
一 : 0 1 背包 设 f [ i ] [ j ] 表示 选了 i 个物品 容量 为 j 的背包,状态直接转移 0 - > V 枚举 和 V - > 0 枚举都可 for(int i=1;i<=n;i++){ for(int j=0;j<=V;j++){ if(w[i]>j)f[i][j]=f[i ...
分类:
其他好文 时间:
2020-07-03 21:01:43
阅读次数:
49
用下`nth_element`逃课,不熟的话在快排的基础上改下随机选择算法也是一样的 ...
分类:
其他好文 时间:
2020-07-03 17:15:27
阅读次数:
58
Kruskal Prim 例题 luogu P3366 【模板】最小生成树 以下代码均可A此题 kruskal Kruskal算法通过并差集维护,从到小枚举每条边,如果两端点不在一个集合,将两端点所在集合合并,并将边权累加到答案中 时间复杂度为$O(m log m)$ 评测记录 code #incl ...
分类:
其他好文 时间:
2020-07-03 12:13:39
阅读次数:
47
1.使用 var scheduler =await StdSchedulerFactory.GetDefaultScheduler(); await scheduler.Start(); var job = JobBuilder.Create<FirstJob>().Build(); var tri ...
分类:
Web程序 时间:
2020-07-03 10:28:09
阅读次数:
71
题目地址 简单的贪心,POJ不能用C11,硬是把C11的特性改回来了 代码 #include <algorithm> #include <iostream> #include <vector> using namespace std; const int INF = 1e9; struct node ...
分类:
其他好文 时间:
2020-07-03 00:43:01
阅读次数:
63