算法
AndrewGhost
IT小虫成长记 Andrew_Ghost@yeah.net
展开
-
国家集训队论文分类整理
国家集训队论文分类整理 距离ACM/ICPC的时间越来越少了,选择性地看一些集训队论文是很有必要的。 (在此给已经看过所有论文的神牛跪了= =) 所以,我在此整理了一下,供大家参考。 组合数学 计数与统计 2001 - 符文杰:《Pólya原理及其应用》 2003 - 许智磊:《浅谈补集转化思想在统计问题中的应用》 2转载 2014-02-23 15:19:12 · 784 阅读 · 0 评论 -
求数组的主元素
#include using namespace std; int main() { int n,a[100],mid,count=0; cin>>n; for(int i=0;i cin>>a[i]; mid=a[0]; for(int i=0;i { if(a[i]==mid) count++; else if(count>0) count--; else原创 2014-05-26 18:55:55 · 671 阅读 · 0 评论 -
杭电ACM题目分类
第一篇 1001 这个就不用说了吧 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最近点对问题,用分治 1008 简单题 1009 贪心 1010 搜索题,剪枝很关键 1011 1012 简单题 1013 简单题(有个小陷阱)转载 2015-03-27 18:27:54 · 366 阅读 · 0 评论 -
最大子集和
采用动态规划和分治。 #include #include #include /* double maxadd(double *shu,int from,int to) { if(to==from) return shu[to]; int middle=(from+to)/2; double m1=maxadd(shu,from,middle); double m2=maxadd(原创 2015-04-15 21:51:13 · 751 阅读 · 0 评论 -
hdu1274
采纳此人代码http://m.blog.csdn.net/blog/MetalSeed/7953175,不过他的外围for循环应该写成ith 代码: #include #include #include #include using namespace std; string s; int fun(i转载 2015-04-26 20:06:46 · 553 阅读 · 0 评论 -
堆排算法实现
堆排,时间复杂度O(nlogn),空间复杂度O(1)。 #include #include using namespace std; void sift(int nums[],int low,int high){ int i=low,j=2*i; while (j<=high) { if(j<high&&nums[j]<nums[j+1]) j++; if(nums[i]<n原创 2016-03-25 22:15:33 · 385 阅读 · 0 评论 -
31. Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible原创 2016-09-15 23:51:54 · 232 阅读 · 0 评论 -
118. Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] class Solution { public:原创 2016-09-16 09:22:42 · 246 阅读 · 0 评论 -
最长递增子序列
动态规划法 时间复杂度O(n*n) c++代码实现:int maxLengthIncSub(int nums[],int n){ int length[n] = {0}; int maxLength = 1; for(int i=0;i<n;i++){ length[i] = 1; for(int j原创 2016-09-17 13:39:27 · 291 阅读 · 0 评论