雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 50 下一页

2013年9月1日

摘要: http://ac.jobdu.com/problem.php?pid=1527对于首尾不相连数组的最大子数组和我们比较熟悉首位相连时,有两种情况,一种是最大子段和在数组中间所以回到上个问题还有一种是最大子段和是首位连接的,这时先找最小的子段和,然后最大子段和就是数组总和减去最小字段和 两种情况取较大值 阅读全文

posted @ 2013-09-01 21:42 huhuuu 阅读(305) 评论(0) 推荐(0) 编辑

摘要: http://pat.zju.edu.cn/contests/pat-a-practise/1057题目的意思是可以在一个可以任意添加于删除整数的集合里随时查找该集合的中位数每次查找用nlogn的方法显然会超时所以要一种方法接近0(N)的查找方法, ( 计算第k大的数会超时!!)比如当前有1,4,7则树状数组的sum结果会是 1,1,1,2,2,2,3现在就变成了二分查找(3+1)/2 ,即2的最左端的位置ps: 2分查找有两种形式 (有一种会出错)int find(int value)// 1,2,3 { int mid,ll=1,rr=3; while(ll#include#i... 阅读全文

posted @ 2013-09-01 11:42 huhuuu 阅读(581) 评论(0) 推荐(0) 编辑

2013年5月16日

摘要: CPen* PenOld,PenNew; CBrush* BrushOld,BrushNew; //选用库存黑色画笔 PenOld = (CPen*)pDC->SelectStockObject(BLACK_PEN); //选用库存浅灰色画刷 BrushOld = (CBrush*)pDC->SelectStockObject(LTGRAY_BRUSH); pDC->Rectangle(100,100,300,300); //关联GDI 库存对象 PenNew.CreateStockObject(WHITE_PEN); pDC->S... 阅读全文

posted @ 2013-05-16 10:26 huhuuu 阅读(702) 评论(0) 推荐(0) 编辑

2013年5月10日

摘要: 惭愧,队列栈集合的容器操作滚瓜烂熟,但是就这个不熟,最近快毕业了,毕业论文上,老师说开静态数组不科学,所以就用这个吧,囧转下别的博客动态创建二维vector数组二维vectorvector<vector <int> > ivec(m ,vector<int>(n)); //m*n的二维vector动态创建m*n的二维vector方法一:vector<vector <int> > ivec;ivec.resize(m);for(int i=0;i<m;i++) ivec[i].resize(n);方法二:vector<vec 阅读全文

posted @ 2013-05-10 21:13 huhuuu 阅读(220) 评论(0) 推荐(1) 编辑

摘要: 给出两个数,已知一个数的进制,求是否可以在某进制下两数相等。此题有个坑,进制在35以内,但是求的进制是远大于35穷举法可以过大部分数据,第7个数据不能过,所以就先穷举,特殊值在二分View Code #include<stdio.h>#include<iostream>#include<stack>#include<math.h>#include<string.h>using namespace std;int main(){ char s1[19],s2[19],st[19]; int tag,radix,max=0; scanf( 阅读全文

posted @ 2013-05-10 16:35 huhuuu 阅读(347) 评论(0) 推荐(0) 编辑

2013年2月5日

摘要: 查询某个数字第N次出现在数列的位置mapView Code #include<stdio.h>#include<map>#include<string.h>#include<iostream>using namespace std;int mhash[1000099];struct data{ int x,y; friend bool operator <(data a,data b){//用map一定要写,不然会出错 if(a.y==b.y) return a.x<b.x; else return a.y<b.y;... 阅读全文

posted @ 2013-02-05 22:27 huhuuu 阅读(249) 评论(0) 推荐(0) 编辑

摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=497&page=show_problem&problem=3146STL的使用,同时注意出栈出队列是的 empty判断View Code #include<iostream>#include<queue>#include<stack>#include<stdio.h>using namespace std;struct data { int v; int k; 阅读全文

posted @ 2013-02-05 20:54 huhuuu 阅读(434) 评论(0) 推荐(0) 编辑

2013年1月13日

摘要: http://ac.jobdu.com/problem.php?cid=1039&pid=22一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。问题1:如果是寻找只有一个出现一次的数字,比较简单的,只要所有数字异或一次即可问题2:找出这两个只出现一次的数字,就要将所有的数字分成两堆,每堆个包含一个出现一次的数字:先把所有数字异或下得到一个数A,A的二进制中的某一位为1,这时就可以以所有数二进制某一位是否为1分成两堆,这是回到了问题一View Code #include<stdio.h>int a[1000009];int b[100 阅读全文

posted @ 2013-01-13 21:09 huhuuu 阅读(433) 评论(0) 推荐(0) 编辑

摘要: http://www.lydsy.com/JudgeOnline/problem.php?id=2982T行,每行一个数,为C(n, m) mod 10007的答案。(1<=m<=n<=200,000,000)View Code /************************************************************** Problem: 2982 User: huhuuu Language: C++ Result: Accepted Time:236 ms Memory:1272 kb*******************... 阅读全文

posted @ 2013-01-13 20:26 huhuuu 阅读(270) 评论(0) 推荐(0) 编辑

2013年1月12日

摘要: http://ac.jobdu.com/problem.php?cid=1039&pid=20统计一个数字在排序数组中出现的次数。因为观察的题目时间复杂度为O(n),所以先到一次遍历动态查找显然不现实,所以用离线查找,将需要查找的先进行排序,在一次遍历提供两组数据以供测试101 2 2 2 3 3 3 3 4 56-1 -9 1 3 4 2101 2 2 2 3 3 3 3 4 5101 2 2 2 3 3 3 3 4 5View Code #include<stdio.h>#include<iostream>#include<algorithm>u 阅读全文

posted @ 2013-01-12 14:20 huhuuu 阅读(435) 评论(0) 推荐(0) 编辑

上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 50 下一页