ICode9

精准搜索请尝试: 精确搜索
  • k近邻算法之python实例2022-03-19 10:02:17

    import math import numpy as np # 在本代码中需要您进行预测我们需要准备多少根香肠。record里的数据分别对应。 #================ def knn(record, target, k): distances = [] record_numbers = [] for i in record: distance = 0 for j

  • 30天英语口语背诵材料:PASSAGE 12 How Technology Helps People?2022-03-06 17:03:09

      Nowadays, we live in an advanced world. We use many new inventions that people long ago never imagined. In the past, people could not regularly communicate with others. It took days ,weeks, or even months just to send a letter. There were no telephones

  • P7293-[USACO21JAN]Sum of Distances P【统计,bfs】2021-12-24 19:34:34

    正题 题目链接:https://www.luogu.com.cn/problem/P7293 题目大意 有 k k k张联通无向图,有 k k k个

  • 【USACO 2021 January Contest, Platinum】Problem 1. Sum of Distances2021-08-17 20:02:23

    \(\text{Solution}\) 一个性质:两个 \(K\) 元组有边相连当且仅当每个点在对应的图中到 \(1\) 有奇偶性相同的路径 那么我们就可以预处理每个图中的点到 \(1\) 的奇偶最短路 再考虑路径长度,显然是 \(\min(\max_{i=1}^k{odd_i}, \max_{i=1}^k{even_i})\) 把它拆开 \(\max_{i=1}^k{odd

  • kruskal算法和prim算法2021-08-13 19:02:16

    1、两种算法都针对无向图2、目的:生成最小生成树 生成树:一个连通图的生成树是指一个连通子图,它含有图中全部n个顶点,但只有足以构成一棵树的n-1条边。                一颗有n个顶点的生成树有且仅有n-1条边,如果生成树中再添加一条边,则必定成环。 最小生成树:在连通网的所有

  • CodeForces 1029E :Tree with Small Distances 思维2021-06-29 21:05:48

    传送门 题目描述 给定一颗有根树(根节点为 1 1 1)。要求往树中加入一些边使得从根节点到其他节点的距离至多是 2 2

  • L1/L2 distances, hyperparameter search, cross-validation2021-06-08 12:05:58

    翻译自 https://cs231n.github.io/classification/ L1/L2 distances, hyperparameter search(超参搜索), cross-validation(交叉验证) Image Classification 图像分类 很多不同的视觉问题如物体检测, 目标分割最后都可以被化简为图像分类问题. 举例 类似如下的输入图像, 计算机都

  • 实验一:递归与分治2021-05-26 17:01:12

    一、循环赛日程安排 1、实验内容 利用分治算法,编程实现循环赛日程表安排问题,并进行时间复杂性分析; 2、实验分析 1.题目理解 (1)根据已经学得知识,8个人大循环赛需要7天。 (2)当比赛人数为2^k时,可以用分治法,多边形轮转法则可以解决一切输入 2.设计分析 (1)输出循环列表,第一列为选手

  • [ABC201E] Xor Distances2021-05-16 11:34:07

    前言 很基础的一道树形DP题。 题目 AtCoder 题目大意: 给定一棵 \(N\) 个点的带权树,询问每个无序点对间的异或距离和。答案对 \(10^9+7\) 取模。 \(2\le N\le 2\times 10^5;0\le w_i\le 2^{60}.\) 讲解 先考虑边权是 \(0,1\) 怎么做。 显然可以直接DP,令 \(dp[i][j]\) 表示从下往上

  • 1117 Eddington Number (25 分)2021-02-28 22:03:10

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E days that one rides more than E miles. Eddin

  • Leetcode126——给定两个单词(beginWord 和 endWord)和一个字典 wordList,找出所有从 beginWord 到 endWord 的最短转换序列2021-02-23 21:34:19

    题目:给定两个单词(beginWord 和 endWord)和一个字典 wordList,找出所有从 beginWord 到 endWord 的最短转换序列。转换需遵循如下规则: 每次转换只能改变一个字母。转换过程中的中间单词必须是字典中的单词。说明: 如果不存在这样的转换序列,返回一个空列表。所有单词具有相同的长度。

  • 基于PCL- 利用kdtree计算点云点距均值2021-02-17 09:32:55

    基于PCL- 利用kdtree计算点云点距均值 //功能:利用kdtree计算点云点距均值 //cloud:代表输入点云 //k:代表定查询点邻域周围最近的K个点 float computeCloudResolution(const pcl::PointCloud<pcl::PointNormal>::ConstPtr &cloud, int k) { double res = 0.0; int n_points =

  • CF1029E Tree with Small Distances2020-11-21 12:32:07

    CF1029E Tree with Small Distances 洛谷传送门 题目描述 给定一颗有根树(根节点为 111)。要求往树中加入一些边使得从根节点到其他节点的距离至多是 222。 求加入边的最小数量。(边全部都是无向的) 输入格式 第一行一个整数 nnn,表示树中的节点个数。 接下来 n−1n−1n−1 行,每行两

  • Edit distance in Java Edit distance with a scoring matrix2020-08-18 08:00:52

    Earlier, we defined edit distance as the minimal number of insertions, deletions and substitutions required to transform one string into another. But the metric can also be formulated in another way. We may assign some cost to each operation and say that

  • Day4 - M - Roads in Berland CodeForces - 25C2020-01-10 11:57:52

    There are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. A

  • 【机器学习实战】计算两个矩阵的成对距离(pair-wise distances)2019-12-11 18:52:33

    矩阵中每一行是一个样本,计算两个矩阵样本之间的距离,即成对距离(pair-wise distances),可以采用 sklearn 或 scipy 中的函数,方便计算。 sklearn: sklearn.metrics.pairwise_distances scipy: scipy.spatial.distance_matrix(用于 p-norm) 或 scipy.spatial.distance.cdist(所有常用距离 m

  • 学号 2019-2020-2314《数据结构与面向对象程序设计》实验九实验报告2019-12-08 20:56:04

    学号 2019-2020-2314《数据结构与面向对象程序设计》实验九实验报告 课程:《程序设计与数据结构》 班级: 1823 姓名: 鞠明翰 学号:20182314 实验教师:王志强 实验日期:2019年12月2日 必修/选修: 必修 1.实验内容 完成图的综合实践 (1)初始化:根据屏幕提示(例如:输入1为无向图,输入2为有向图)初始

  • Python3入门机器学习 经典算法与应用2019-09-25 11:51:27

    邻近算法,或者说K最近邻(kNN,k-NearestNeighbor)分类算法是数据挖掘分类技术中最简单的方法之一。所谓K最近邻,就是k个最近的邻居的意思,说的是每个样本都可以用它最接近的k个邻居来代表。kNN算法的核心思想是如果一个样本在特征空间中的k个最相邻的样本中的大多数属于某一个类别,则该

  • python内的列表的argsort函数功能2019-04-11 15:55:33

     代码如下    distances = sqDistances**0.5     print("距离和开方",distances)     sortedDistIndices = distances.argsort() #argsort函数返回的是数组值从小到大的索引值     print("从小到大的距离",sortedDistIndices) 运行结果如下 距离和开方 [9.6      

  • 【CodeChef - CLIQUED 】Bear and Clique Distances(建图,缩点技巧,思维)2019-04-06 22:52:26

    题干: 解题报告:   主要就是在于怎么处理那个前K个点:组成一个团。换句话说,缩成一个点。先直接当成每个点多了k条边来处理,T了。想想也是啊,要是K=1e5,那就是1e10条边了。。刚开始尝试了半天缩点,后来发现其实不用,只需要把这k个点都连到一个新点上,最后再连回去,然后直接Dijkstra就可

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有