C98或C99中的库为:<cassert> 或<assert.h> 运行时断言,故明思议是当程序在运行的时候才作为判决,可以认为是对参数的有效性的判断。 而静态断言,是对参数的条件判断提前做了,在预编译的时候进行完成的。如: assert(n>0); 该条件只会在当arrayAlloc的时候才会进行 ...
分类:
编程语言 时间:
2017-03-10 23:37:20
阅读次数:
358
用了两个pii代码有点长…… 记忆化搜索主要还是用用dp数组去记录并更新状态 ...
分类:
其他好文 时间:
2017-03-03 19:01:54
阅读次数:
222
方法:kmp code: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 #include <string> 6 #include <vector> 7 #include ...
分类:
其他好文 时间:
2017-02-02 19:57:28
阅读次数:
263
方法:数论 其实不是很明白,为什么这个公式可行 a^b % m = a^(b%phi[m] + phi[m]) % m code: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream ...
分类:
其他好文 时间:
2017-02-01 10:53:48
阅读次数:
245
方法:Trie 本题其实就是trie的实现,每个节点需要记录两个值,深度 和 visit的次数,答案便是 max(深度 * visit的次数)。 数组实现code: 心血来潮用动态分配空间写了一个,注意要合理释放空间,比如写一个delete(node * root) 的函数,不过注意最好不要写成re ...
分类:
其他好文 时间:
2017-01-30 16:17:18
阅读次数:
206
方法:对数,暴力 我们需要求出最小的e,是的存在一个i > len(n) , 满足 floor[2^e/ (10^i)]= n, 即 n*10^i < 2^e < (n+1)*10^i。对两边同时取log10 (以10为底的对数,记作lg),得到 lg(n) + i < e*lg(2) < lg(n ...
分类:
其他好文 时间:
2017-01-30 10:39:46
阅读次数:
260
题目链接:http://poj.org/problem?id=2069 题意:求一个半径最小的球,使得它可以包围住所有点。 模拟退火,圆心每次都去找最远那个点,这样两点之间的距离就是半径,那么接下来移动的方向肯定就是朝着这个最远点移动,保证比例相同且在球内的情况下移动。 不看题解想不到,这个东西有点 ...
分类:
其他好文 时间:
2016-12-28 21:02:27
阅读次数:
256
#include<iostream>#include<cassert> using namespace std; template <class T>//链栈 struct LinkNode{T data;LinkNode<T> *Link;LinkNode(LinkNode<T> *pr=NULL ...
分类:
其他好文 时间:
2016-10-19 23:58:26
阅读次数:
446
#include<iostream>#include<cassert>#include<cstring>#include<string>using namespace std; int maxLength=100;const int stackIncreament = 20;template<cla ...
分类:
编程语言 时间:
2016-10-16 11:47:39
阅读次数:
168
assert是定义在头文件cassert中的宏 其作用是如果他的返回值不为真则终止程序。 assert(expression); if 为假,先向stderr打印一条错误信息,再用abort终止程序 缺点:频繁调用影响程序性能,增加程序开销。 可在调用cassert后,用#define NDEBUG ...
分类:
其他好文 时间:
2016-09-21 07:56:42
阅读次数:
136