上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 43 下一页
摘要: 第一题是整数的方阵,求其中的子方阵,和最大。返回最大和以及子方阵宽度。因为做了topcoder的题,所以比较顺手,O(n^3)的复杂度。pair maxiSum(vector > &a) { //first is n second is sum int N = a.size(); in... 阅读全文
posted @ 2014-08-08 22:50 阿牧遥 阅读(293) 评论(0) 推荐(0)
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13005好题。最暴力是试验2^n种跳法。然后有从结果入手,那么最终的左右是i, j,有n^2种(每种4个跳法),然后花O(n)的时间去验证。最后的正解比较有意思,就是观察到必须向里跳... 阅读全文
posted @ 2014-08-08 17:14 阿牧遥 阅读(192) 评论(0) 推荐(0)
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13040DFS集合全排列+LCM和GCD。但事实上,有更简单的算法,列在下面,就是观察到不能整除x的对我们无效。#include #include using namespace s... 阅读全文
posted @ 2014-08-08 15:23 阿牧遥 阅读(150) 评论(0) 推荐(0)
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13091解方程,对中国孩子太简单了。#include #include using namespace std;class LongLongTripDiv2 {public: ... 阅读全文
posted @ 2014-08-08 14:48 阿牧遥 阅读(147) 评论(0) 推荐(0)
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13147此题关键在于发现ABAB的组合最多有26*26种,可以穷举,然后用判断子序列~#include #include using namespace std;class Long... 阅读全文
posted @ 2014-08-08 14:29 阿牧遥 阅读(135) 评论(0) 推荐(0)
摘要: http://lintcode.com/en/problem/majority-number-iii/此题是黑帮火并的思想,就是如果有k个不同的元素,那么把他们全去掉,不影响剩下的元素中的“众数”。如果“众数”在k个里面,不影响,不在,也不影响。原题确认只有一个“众数”,那么就不用再扫一遍了。当然也... 阅读全文
posted @ 2014-08-07 22:45 阿牧遥 阅读(963) 评论(3) 推荐(0)
摘要: https://oj.leetcode.com/problems/reverse-words-in-a-string/分三步,1. reverse line; 2. reverse words; 3. erase extra spaces;class Solution {public: voi... 阅读全文
posted @ 2014-08-02 20:14 阿牧遥 阅读(178) 评论(0) 推荐(0)
摘要: https://www.topcoder.com/stat?c=problem_statement&pm=13146&rd=15852// Need carefully calc the shift and the final index#include using namespace std;cl... 阅读全文
posted @ 2014-08-02 17:39 阿牧遥 阅读(172) 评论(0) 推荐(0)
摘要: C++优先队列类似队列,但是在这个数据结构中的元素按照一定的断言排列有序。它的头文件为。由于适配器不支持迭代,一个 priority_queue 将有没有关联的迭代器。函数列表:empty() 如果优先队列为空,则返回真 pop() 删除第一个元素 push() 加入一个元素 size() 返回优先... 阅读全文
posted @ 2014-08-02 15:54 阿牧遥 阅读(229) 评论(0) 推荐(0)
摘要: https://community.topcoder.com/stat?c=problem_statement&pm=13192#include #include #include using namespace std;class BoxesDiv2{public: vector power2; ... 阅读全文
posted @ 2014-08-02 15:53 阿牧遥 阅读(186) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 43 下一页