雕刻时光

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

2012年3月18日

摘要: 有一些由“_"和"#"组成的图形,图形中由"#"拼成了"B"、"M"、"W"三种字母,。用程序识别这些字母,统计三个字母的个数。___###############___________________________________###################_______________________________#####################_____________________________#####_____________#####_____ 阅读全文

posted @ 2012-03-18 19:43 huhuuu 阅读(378) 评论(0) 推荐(0) 编辑

2012年3月15日

摘要: 难点不在贪心,在于对字符串的处理,字符串处理为数字sscanf就可以了View Code #include<iostream>#include<algorithm>#include<stdio.h>#include<string.h>#include<math.h>using namespace std;struct data{ double x,y; int time;}s[100009];double dis[100009];double fdis(double x0,double y0,double x1,double y1){ 阅读全文

posted @ 2012-03-15 21:42 huhuuu 阅读(175) 评论(0) 推荐(0) 编辑

2012年3月10日

摘要: 3abxcybzca转化---->1 1 12 2 13 2 1i :1->nj:1->ndp[i][j]=min(dp[i][j],dp[i-1][j+1]);View Code #include<stdio.h>char map[1009][1009];int a[1009][1009];int min(int a,int b){ if(a>b)return b; else return a;} int main(){ int n; while(scanf("%d",&n)!=EOF) { if(n==0)return 0; 阅读全文

posted @ 2012-03-10 22:19 huhuuu 阅读(284) 评论(0) 推荐(0) 编辑

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2855实际就是求fibonacci的2*n个用二分矩阵算View Code #include<stdio.h>#include<string.h>int mod;struct data{ int map[2][2];};data matrix(data a,data b)//矩阵乘法{ int n=2; int i,j,k; data re; for(i=0;i<n;i++) { for(j=0;j<n;j++) { int... 阅读全文

posted @ 2012-03-10 19:33 huhuuu 阅读(231) 评论(0) 推荐(0) 编辑

2012年2月25日

摘要: 直线x=a,x=b又有n条线段求吧区域分成几个空间部分顶点-线段+空间=3把线段与两条直线相交的点ll,rr求出来按min(ll,rr)排序判断来降低时间复杂度View Code #include<stdio.h>#include<iostream>#include<algorithm>using namespace std;struct data{ double ll,rr; double duan; double min;}s[30099];double cmp(data a,data b){ return a.min<b.min;}int mai 阅读全文

posted @ 2012-02-25 21:48 huhuuu 阅读(259) 评论(0) 推荐(1) 编辑

2012年2月13日

摘要: http://poj.org/problem?id=3040注意到这么一句话where each denomination of coin evenly divides the next-larger denomination想到贪心,排个序,从高往下取同时加个最小公倍数的优化时间0msView Code #include<iostream>#include<algorithm>#include<string.h>using namespace std;int hash1[21];struct data{ int v,b;}s[29];int cmp(dat 阅读全文

posted @ 2012-02-13 22:06 huhuuu 阅读(480) 评论(0) 推荐(0) 编辑

2012年2月10日

摘要: 特殊数排列组合联系好题如:9876543先算特殊数有6位数有几种在统计有7位时有几个View Code #include<stdio.h>#include<string.h>#include<iostream>#include<stack>using namespace std;bool hash[10];__int64 p(__int64 a,__int64 b){ if(a>b)return 0; __int64 all=1; while(a--) { all=all*b; b--; } return all;}__int64... 阅读全文

posted @ 2012-02-10 14:13 huhuuu 阅读(293) 评论(0) 推荐(0) 编辑

2012年2月8日

摘要: 区间覆盖最小代价由于N<=10000排序后想到N*N的遍历不断更新add[i](表示到i最小代价)里的值,使之最小View Code #include<stdio.h>#include<iostream>#include<algorithm>using namespace std;const int maxint=999999999;struct data{ int ll,rr,c;}s[10009];int add[10009];int cmp(data a,data b){ if(a.ll==b.ll) return a.rr<b.rr; e 阅读全文

posted @ 2012-02-08 16:52 huhuuu 阅读(333) 评论(0) 推荐(0) 编辑

摘要: DIJK水过View Code #include<stdio.h>#include<string.h>#include<stack>#include<iostream>using namespace std;int n,m;int map[1009][1009];int path[1009];int dis[1009];bool used[1009];const int maxint=999999999;void dijk(){ memset(path,-1,sizeof(path)); memset(used,0,sizeof(used)); 阅读全文

posted @ 2012-02-08 14:48 huhuuu 阅读(581) 评论(0) 推荐(0) 编辑

2012年2月5日

摘要: 有n个小朋友坐成一圈,每人有ai个糖果。每人只能给左右两人传递糖果。每人每次传递一个糖果代价为1。不是圈的话,就像平分纸牌,加了个圈的话假设平均数是x,且a1给an了k个(k<0说明是an给a1了k个),那么总代价就可以算出来:令si=sum(a1..i)-ix,则总代价=sum|si-k|。易知k为中位数时此值最小。问题转化为求中位数……View Code #include<stdio.h>#include<iostream>#include<algorithm>#include<math.h>using namespace std;in 阅读全文

posted @ 2012-02-05 20:59 huhuuu 阅读(1698) 评论(0) 推荐(1) 编辑

上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 50 下一页