Avatar

Organizations

4 results for 枚举
  • 由于对计算机科学的热爱,以及有朝一日成为 「Bessie 博士」的诱惑,奶牛 Bessie 开始攻读计算机科学博士学位。

    经过一段时间的学术研究,她已经发表了 N 篇论文,并且她的第 i 篇论文得到了来自其他研究文献的 ci 次引用。

    Bessie 听说学术成就可以用 h 指数来衡量。

    h 指数等于使得研究员有至少 h 篇引用次数不少于 h 的论文的最大整数 h。

    例如,如果一名研究员有 4 篇论文,引用次数分别为 (1,100,2,3),则 h 指数为 2,然而若引用次数为 (1,100,3,3) 则 h 指数将会是 3。

    为了提升她的 h 指数,Bessie 计划写一篇综述,并引用一些她曾经写过的论文。

    由于页数限制,她至多可以在这篇综述中引用 L 篇论文,并且她只能引用每篇她的论文至多一次。

    请帮助 Bessie 求出在写完这篇综述后她可以达到的最大 h 指数。

    注意 Bessie 的导师可能会告知她纯粹为了提升 h 指数而写综述存在违反学术道德的嫌疑;我们不建议其他学者模仿 Bessie 的行为。

    acwing 简单 枚举 贪心 双指针 Created Thu, 17 Mar 2022 16:37:13 +0800
  • You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.

    You are also given a 2D integer array edges where \(edges[i] = [from_i, to_i, weight_i]\) denotes that there exists a directed edge from \(from_i\) to \(to_i\) with weight \(weight_i\).

    Lastly, you are given three distinct integers src1, src2, and dest denoting three distinct nodes of the graph.

    Return the minimum weight of a subgraph of the graph such that it is possible to reach dest from both src1 and src2 via a set of edges of this subgraph. In case such a subgraph does not exist, return -1.

    A subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.

    leetcode 困难 枚举 最短路 Created Sun, 13 Mar 2022 20:28:53 +0800
  • 农夫约翰的 N 头奶牛站在一维长围栏的不同位置。

    第 i 头牛位于位置 xi,其所属品种为 bi(根西岛牛或荷斯坦牛)。

    所有奶牛的位置各不相同。

    约翰想给一段连续区间内的奶牛拍摄一张照片,用来在乡村集市上展览。

    但是我们希望他所有品种的奶牛都能在照片中得到公平的展示。

    因此,他希望确保无论照片中出些哪些品种的奶牛,每种品种的奶牛在照片中的数量都必须相等。

    例如,一张照片中只包含荷斯坦牛是可以的,包含荷斯坦牛和根西岛牛各 27 头也没问题,但是包含 10 头荷斯坦牛和 9 头根西岛牛则不可以。

    请确定,约翰可以拍下的满足以上条件的照片的最大尺寸。

    照片的尺寸是指照片中奶牛最大和最小位置之间的差。

    约翰最终可能只拍下一头奶牛,这种情况下,照片尺寸为 0。

    acwing 简单 枚举 前缀和 哈希表 Created Thu, 20 Jan 2022 12:57:54 +0800
  • 如果一个正整数,其各个数位上的数字均满足要么是 0,要么是 1,则称该数字为 01 数。

    例如,1 和 10 都是 01 数。

    给定一个整数 n。

    请你计算,1∼n 中有多少个 01 数。