题目链接:http://poj.org/problem?id=2054 贪心算法,思路参考yxc,涉及树的合并与缩点,将所有触发点构成的链全部缩进根节点即可得到最终的结果。证明: 代码如下: #include<iostream> using namespace std; const int maxn ...
分类:
编程语言 时间:
2020-06-16 15:01:14
阅读次数:
52
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>操作数组的10个方法</title> </head> <body> <script type="text/javascript"> /* 方法一:shift() 删除数组的第一个值 ...
分类:
编程语言 时间:
2020-06-16 14:47:24
阅读次数:
51
function findIndexByKeyValue(arr, key, valuetosearch) { for (var i = 0; i < arr.length; i++) { if (arr[i][key] == valuetosearch) { return i; } } retur ...
分类:
编程语言 时间:
2020-06-16 13:19:40
阅读次数:
80
求 $n$ 元环的 $n$ 染色方案数,旋转同构,翻转不同构,颜色可以不用完。 ...
分类:
其他好文 时间:
2020-06-16 13:14:59
阅读次数:
66
\(Link\) \(\text{Solution:}\) 把奶牛的忍耐度转化为线段,则题目转化为选择一些点使得覆盖的线段尽可能多。一个点只能覆盖一条线段。 考虑将点按照位置排序,线段按照右端点排序。排序后显然线段的最低耐受程度是递增的,那么我们显然用位置最靠左的点最优,因为以后它一定覆盖不了其它的 ...
分类:
其他好文 时间:
2020-06-16 12:56:22
阅读次数:
52
1 public boolean deleteCustomer(int index){ 2 boolean ret=false; 3 if(index<total && index>=0){ 4 if(customers[index].getName()!=null){ //以name作为此位置是否 ...
分类:
其他好文 时间:
2020-06-16 01:11:56
阅读次数:
55
题目描述 给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最小深度 2. 题目链接: https: ...
分类:
其他好文 时间:
2020-06-15 23:16:51
阅读次数:
86
二维数组与稀疏数组互转 注意:二维数组判空 package array; /** * 稀疏数组 */ public class SparseArray { private static int n = 4; private static int m = 5; private int[][] spar ...
分类:
编程语言 时间:
2020-06-15 23:03:12
阅读次数:
63
C#表达式体方法 , expression-bodied method ...
第1关:继承 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace K1 { public abstr ...