Description 在黑板上写了N个正整数组成的一个数列,进行如下操作: 每次擦去其中的两个数a和b,然后在数列中加入一个数a×b+1,如此下去直至黑板上 剩下一个数,在所有按这种操作方式最后得到的数中,最大的为max,最小的为min, 则该数列的极差定义为M=max-min。 请你编程,对于给 ...
分类:
其他好文 时间:
2020-07-18 16:12:58
阅读次数:
81
Description 有n个小朋友坐成一圈,每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。求使所有人获得均等糖果的最小代价。 Input 小朋友个数n,下面n行 ai Sample Input 4 1 2 5 4 Sample Output 4 思 思维难度高的贪心题 ...
分类:
其他好文 时间:
2020-07-18 13:34:55
阅读次数:
72
前言 贪心算法,记得学的时候还是大学的时候,再次来总结一下吧。 贪心算法并不是指具体的固定代码,而是指一种思路,加入我们每次都选最好的选择,那么很大可能会得到最好的结果。 题目: 正文 思路,加入把k1到k5轮询一遍,发现k1、k2、k3可以覆盖范围最多,随便取一个,假设取k1。 那么剩下广播地区就 ...
分类:
编程语言 时间:
2020-07-18 00:51:35
阅读次数:
67
N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest children are divided into three groups (it i ...
分类:
其他好文 时间:
2020-07-18 00:42:12
阅读次数:
76
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
http://poj.org/problem?id=2406 http://poj.org/problem?id=1961 几乎是一个题 1961是对于第 \(i\) 位,求 \([1,i]\) 能不能由一段字符循环一次以上组成,输出 \(i\) 和这样的长度最小的循环节循环次数 2406是只对第 ...
分类:
其他好文 时间:
2020-07-17 13:49:40
阅读次数:
47
Tom and Jerry are going on a vacation. They are now driving on a one-way road and several cars are in front of them. To be more specific, there are nn ...
分类:
其他好文 时间:
2020-07-17 09:30:42
阅读次数:
82
题目来源:leetcode300 最长上升子序列 题目描述: 给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合 ...
分类:
其他好文 时间:
2020-07-17 09:30:26
阅读次数:
61
如何理解与实现最小生成树呢?Prim算法与Kruskal算法背后的思想又是怎么样的呢?一起来探索吧~ ...
分类:
编程语言 时间:
2020-07-16 22:06:12
阅读次数:
134
Running Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8597 Accepted: 3213 Description The cows are trying to become better athletes, so B ...
分类:
其他好文 时间:
2020-07-16 18:10:43
阅读次数:
60