码迷,mamicode.com
首页 >  
搜索关键字:smallest sub-array    ( 590个结果
UVA 11997 - K Smallest Sums(优先队列+多路合并)
UVA 11997 - K Smallest Sums题目链接题意:给定k个数组,每一个数组k个数字,要求每一个数字选出一个数字,构成和,这样一共同拥有kk种情况,要求输出最小的k个和思路:事实上仅仅要能求出2组的前k个值,然后不断两两合并就能够了,由于对于每两组,最后答案肯定是拿前k小的去组合。然...
分类:其他好文   时间:2014-10-09 01:48:37    阅读次数:186
uva 11997 K Smallest Sums
首先对每行进行排序,并对与前两行有$A = a_1 \leq a_2 \leq \cdots \leq a_k$和$B = b_1 \leq b_2 \leq \cdots \leq b_k$。首先把所有的$b_i , i\in [1,k]$与$a_1$进行求和,并加入优先队列中。其中最小的必然是$...
分类:其他好文   时间:2014-10-02 00:24:41    阅读次数:202
选择排序
Selection Sort选择排序The idea of the selection sort is to find the smallest element in the list and exchange it with theelement in the first position. Th...
分类:其他好文   时间:2014-09-25 19:44:07    阅读次数:223
UVA12300-Smallest Regular Polygon
给出两点,求经过这两点的正n边形的最小面积 大白鼠上说要注意精度,我没觉得精度有什么影响,然后就过了 我的做法: 相当于这两点构成的线段是正n边形的最长弦 我的代码: #include #include #include #include #include #include #include #include #include #include using names...
分类:其他好文   时间:2014-09-11 22:26:22    阅读次数:215
Find longest contiguous sub array
It's still an Amazon interview question. Given an array containing only stars '*' and hashes '#' . Find longest contiguous sub array that will cont...
分类:其他好文   时间:2014-09-09 21:20:49    阅读次数:254
UVA11997K Smallest Sums(优先队列+二路归并)
题目:UVA11997K Smallest Sums(优先队列+二路归并) 题目大意:求K个最小和。给出K行,每行有K个数,在每行中取一个元素相加,求这些和中最小的k的值。 解题思路:每一行排列一下,那么对于两张表a1                                                                             b1 ...
分类:其他好文   时间:2014-09-09 12:45:58    阅读次数:209
UVA 11997 【K Smallest Sums】
【题意分析】本题目是要求总和最小的k个值,当然我们没有必要把所有的值全部求一次,我们首先应该对每组元素进行排序。然后根据两两合并的观点节约空间(先把前两组数据合并为一组数据,最后把下面的每一组数据和之前合并所得的那组数据进行合并)。那么最后剩下的那组数据中的前k个数字就是最小的数字。【借鉴之处】本题...
分类:其他好文   时间:2014-09-06 17:15:53    阅读次数:257
乌拉姆数列 Euler167
昨天 yep 问了一个问题: For two positive integers a and b, the Ulam sequence U(a,b) is defined by U(a,b)1 = a, U(a,b)2 = b and for k > 2, U(a,b)k is the smallest integer greater than U(a,b)(k-1) which can...
分类:其他好文   时间:2014-08-31 20:07:21    阅读次数:359
ZOJ - 1136 Multiple (同余+BFS)
Description a program that, given a natural number N between 0 and 4999 (inclusively), and M distinct decimal digits X1,X2..XM (at least one), finds the smallest strictly positive multiple of N that ...
分类:其他好文   时间:2014-08-26 21:34:06    阅读次数:342
POJ 2305 Basic remains(JAVA练习)
Description Given a base b and two non-negative base b integers p and m, compute p mod m and print the result as a base b integer. p mod m is defined as the smallest non-negative integer k such tha...
分类:编程语言   时间:2014-08-25 19:20:04    阅读次数:230
590条   上一页 1 ... 54 55 56 57 58 59 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!