1 2 3 4 5 ··· 7 下一页
摘要: http://codeforces.com/contest/1095/problem/C 题意:给n找出k个2的幂,加起来正好等于n。例如 9,4:9 = 1 + 2 + 2 + 4 思路:首先任何数都能表示成2的次幂的和,其次很容易发现,n和k都是二的次幂的情况是最基础的,因为可以分成k个n/k, 阅读全文
posted @ 2018-12-30 00:18 GeniusYang 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 给出字符串S和字符串T,计算S的不同的子序列中T出现的个数。 子序列字符串是原始字符串通过删除一些(或零个)产生的一个新的字符串,并且对剩下的字符的相对位置没有影响。(比如,“ACE”是“ABCDE”的子序列字符串,而“AEC”不是)。 样例 给出S = "rabbbit", T = "rabbit 阅读全文
posted @ 2017-09-30 01:04 GeniusYang 阅读(274) 评论(0) 推荐(0) 编辑
摘要: dp[i][j]代表以i结尾,长度为j的最小的字串 因为这个数字会很长 所以不能用数字来dp,必须用字符串来dp 注意一下因为是字符串 所以要去掉前导零 阅读全文
posted @ 2017-09-29 10:44 GeniusYang 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /* 4 * @param A: An integer array 5 * @param queries: The query list 6 * @return: The number of element in the array th 阅读全文
posted @ 2017-09-26 22:41 GeniusYang 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 右边的括号不能比左边多 阅读全文
posted @ 2017-09-25 19:02 GeniusYang 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 /* 4 * @param costs: n x 3 cost matrix 5 * @return: An integer, the minimum cost to paint all houses 6 */ 7 const int inf = 0x3f3f3f3f; ... 阅读全文
posted @ 2017-09-24 10:06 GeniusYang 阅读(431) 评论(0) 推荐(0) 编辑
摘要: ip地址的每个区域值不大于255 且不能有前导零 阅读全文
posted @ 2017-09-18 20:11 GeniusYang 阅读(237) 评论(0) 推荐(0) 编辑
摘要: dfs会爆栈 可以 bfs或者用栈模拟函数 阅读全文
posted @ 2017-09-18 20:09 GeniusYang 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * // This is the interface that allows for creating nested lists. 3 * // You should not implement it, or speculate about its implementation 4 * class NestedInteger { 5 * public: 6... 阅读全文
posted @ 2017-09-13 00:45 GeniusYang 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 只交换一次的情况原来 |Suma - Sumb|交换后 Suma - xi + yj - (sumb - yj + xi) = suma - sumb + 2(yj - xi) -> 0则在确定xi的情况下 需要在 b序列里找到 最接近 xi 的 (suma - sumb) /2 + yj的 yj 阅读全文
posted @ 2017-08-29 23:59 GeniusYang 阅读(194) 评论(0) 推荐(0) 编辑
1 2 3 4 5 ··· 7 下一页