摘要: find a+b+c=d , 3sum problem 枚举dhttp://poj.org/problem?id=2549View Code const int MM = 111111;int N;int num[MM];void get_data() { int i,j,k; for(i=0;i<N;i++) scanf("%d",&num[i]);}//choose three number from a set,then a+b+c=0void threesum(int n,int*val) { int i,j,k,a,b,c,tmp,l; sort(v 阅读全文
posted @ 2013-05-02 20:58 zhang1107 阅读(175) 评论(0) 推荐(0)
摘要: 参考:http://en.wikipedia.org/wiki/3SUM//choose three number from a set,then a+b+c=0View Code //choose three number from a set,then a+b+c=0//其实就是两头逼近,复杂度O(N^2)void threesum(int n,int*val) { int i,j,k,a,b,c,tmp,l; sort(val,val+n); for(i=0;i<n-2;i++) { a=val[i], j=i+1, k=n-1; while... 阅读全文
posted @ 2013-05-02 20:55 zhang1107 阅读(149) 评论(0) 推荐(0)
摘要: 资料:http://wenku.baidu.com/view/1845fdc75fbfc77da269b1ae.html http://wenku.baidu.com/view/e7c220c52cc58bd63186bdae.html 阅读全文
posted @ 2013-05-02 20:18 zhang1107 阅读(113) 评论(0) 推荐(0)