题意:将n个数字分成两组,两组分别组成一个数字,问两个数字的最小差值。要求,当组内数字个数多于1个时,组成的数字不允许有前导0。(2<=n<=10,每个数字范围是0~9) 分析: 1、枚举n个数字的全排列。 2、当两组数字个数相同或只差1时组成的两个数字才可能出现最小差值。 3、0~cnt/2 - ...
分类:
其他好文 时间:
2017-03-06 23:35:33
阅读次数:
179
【React】 1、The smallest React example looks like this: 2、You can embed any JavaScript expression in JSX by wrapping it in curly braces. 3、After compila ...
分类:
其他好文 时间:
2017-02-12 21:15:06
阅读次数:
221
感谢 http://hi.baidu.com/%C0%B6%C9%ABarch/blog/item/f9d343f49cd92e53d7887d73.html 的博主! 思路: 我们要找到n个smallest的数,用贪心法可以解决这一问题。 (1)维护两个数组,a和b,以及一个大根堆p 循环不变式:... ...
分类:
其他好文 时间:
2017-02-05 22:39:37
阅读次数:
231
题目:POJ 2718 思路: 分为奇数和偶数两种情况进行处理,输入个数为奇数的时候,无须穷举,最小差是一定的,如0 1 2 3 4,最小差为102 - 43。 输入个数为偶数的时候,用next_permutation穷举。 没有AC…… 总结: 在不知道输入个数的情况下接收,用gets()接收一行 ...
分类:
其他好文 时间:
2017-02-03 12:34:34
阅读次数:
154
原题链接在这里:https://leetcode.com/problems/find-k-pairs-with-smallest-sums/ 题目: You are given two integer arrays nums1 and nums2 sorted in ascending order ...
分类:
其他好文 时间:
2017-02-02 17:22:31
阅读次数:
171
A more programming-like solution, is to hack the problem from simple: we try each possble base value, and see which 111..11 fits target number - using ...
分类:
其他好文 时间:
2017-01-31 10:32:45
阅读次数:
226
Description has only two Sentences Problem Description an = X*an-1 + Y and Y mod (X-1) = 0.Your task is to calculate the smallest positive integer k t ...
分类:
其他好文 时间:
2017-01-22 07:56:47
阅读次数:
300
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. Id is the primar ...
分类:
数据库 时间:
2017-01-17 08:03:36
阅读次数:
238
problem 5:Smallest multiple 题意:求最小的正数,使得其可以被1-20整除 代码如下: 有关函数: 1 long long gcd(long a,long b){ 2 return b==0?a:gcd(b,a%b); 3 } 4 5 long long lcm(long ...
分类:
其他好文 时间:
2017-01-16 21:24:11
阅读次数:
190
Implement a stack with min() function, which will return the smallest number in the stack. It should support push, pop and min operation all in O(1) c ...
分类:
其他好文 时间:
2017-01-10 10:13:00
阅读次数:
146