2014年10月9日

K&R——第五章 指针与数组

摘要: #include #define maxsize 5000char buf[maxsize];char *head = buf;char *new(int size){ //分配元素字长 //可用内存分配完毕 if (maxsize - (buf - head) < size) return ... 阅读全文

posted @ 2014-10-09 20:58 杰斯特丹第 阅读(121) 评论(0) 推荐(0) 编辑

2014年9月26日

3.4 熟练掌握动态规划——状态压缩DP

摘要: 从旅行商问题说起—— 给定一个图,n个节点(n>(v-1) & 1))//如果这个点还没有走过 { int val=DP(v,S | (1<<(v-1))); if (val!=INF) { dp[K][S]=min(dp[K][S],val+dist); } } } r... 阅读全文

posted @ 2014-09-26 16:18 杰斯特丹第 阅读(206) 评论(0) 推荐(0) 编辑

Poj 1742 Coins

摘要: 题意: 给定N个面值,a1..an,每种面值都有c1..cn个,问从1..m的面值中,有多少个可以用已经给定的面值组成?分析: 还记得“多重组合数”问题么? DP[K][N]——用前N种数字组成K,第N种可以剩下最多多少个。 证明分析就不给出了,见前面的博文吧。时间复杂度为K*N这道题... 阅读全文

posted @ 2014-09-26 14:24 杰斯特丹第 阅读(116) 评论(0) 推荐(0) 编辑

2014年9月19日

支持C++11标准

摘要: 设置CB下的GCC。Settings->Compiler->Compiler Settings勾选Have g++ follow the C++11 ISO C++ language standard确定即可!设置g++ 在g++中使用c++11标准 g++ -std=c++0x a.cpp 阅读全文

posted @ 2014-09-19 15:05 杰斯特丹第 阅读(179) 评论(0) 推荐(0) 编辑

2014年9月15日

第三章 poj 1064——关于带精度的二分法

摘要: /* 题意:给定n个实数l[i],给定一个k 问:求最大的ans,使得sum l[i]/ans i=1 to n >=k,且ans最大*/#include #include #include #define range(i,a,b) for (int i=a;ib ? a : b;}bool c... 阅读全文

posted @ 2014-09-15 09:40 杰斯特丹第 阅读(212) 评论(0) 推荐(0) 编辑

2014年9月10日

前两章总结

摘要: 第一章: 1.时间估算。 2.“抽签”优化 3.Ants Poj 1852的思考过程第二章: 1.next_permutation函数 2.栈内存和堆内存——关于内存抽象。 * 3.Best Cow Line Poj 3617 * 4.霍夫曼编码 5.01背包的空间优化 6.memse... 阅读全文

posted @ 2014-09-10 10:49 杰斯特丹第 阅读(132) 评论(0) 推荐(0) 编辑

2014年9月3日

基于python脚本的对拍debug

摘要: 首先,这是python脚本import os;for i in range(0,20): print ("Case:"+str(i)); print ("randoming"); os.system("randomdata.exe"); print("running righ... 阅读全文

posted @ 2014-09-03 21:54 杰斯特丹第 阅读(552) 评论(0) 推荐(0) 编辑

2014年9月2日

upper_bound——自己的实现

摘要: int BSearch(){ int ln(1),rn(n+1); while(ln+1>1; if (Check(mid)) { ln=mid; //mid符合标准,区间变为[mid,rn) } else { rn=mid; /... 阅读全文

posted @ 2014-09-02 20:18 杰斯特丹第 阅读(214) 评论(0) 推荐(0) 编辑

2014年9月1日

多重部分和问题

摘要: 描述: N种不同数字ai每种mi个,判断是否可以选择若干个使得和为K N=ai) { if (Dp[i-1][k]) { //上一个已经可以构成 ... 阅读全文

posted @ 2014-09-01 20:04 杰斯特丹第 阅读(169) 评论(0) 推荐(0) 编辑

next_permutation函数

摘要: 头文件: algorithm参数: next_permutation(first,last) next_permutation(first,last,cmp)first,last为两个iterator,分别指向目标的头和尾,cmp是一个bool函数,接受两个目标序列值,返回boolne... 阅读全文

posted @ 2014-09-01 19:30 杰斯特丹第 阅读(212) 评论(0) 推荐(0) 编辑

导航