05 2019 档案
摘要:#includeusing namespace std;int main(){ //设想要建立一个rows行,cols列的矩阵 //使用new进行新建 int rows, cols; cin >> rows >> cols; ...
阅读全文
摘要:题意:给出 n 个数,选取其中若干个数分别组成至多 k 组,要求每组内最大值与最小值的差值不超过5,求最后被选上的总人数。题解:将a[1∼n] 从小到大排序,f[i][j] 表示到第 i 个数为止,已经组成 j 组,最多可以包含多少个数。那么,考虑第 ...
阅读全文
摘要:以前用这两个函数的时候,简单看了几句别人的博客,记住了大概,用的时候每用一次就弄混一次,相当难受,今天对照着这两个函数的源码和自己的尝试发现:其实这两个函数只能用于 “升序” 序列。为什么还要加个引号呢?因为比较规则可以自定义,如果你非要把比较规则定义...
阅读全文
摘要:对于3维的,可以用结构体来储存,详细见下列代码。样例可以过,不过能不能ac还不知道,疑似poj炸了,#include#include#include#includeusing namespace std;const int INF = 0x3f3f3f...
阅读全文
摘要:#include #include #include using namespace std; int n, k; const int maxn = 10; char chess[maxn][maxn]; int vis_y[maxn]; //判断该列是否已经有棋子 int sum; void dfs(int x, int rem) { if(rem == 0) { ...
阅读全文
摘要:题目链接题意人要从迷宫走出去,火会向四个方向同时扩散分析两步bfs,先出火到达各地时的时间(设初始时间为0,人每走一步为1s,在着一步内火可以向四周可触及的方向同时扩散),然后在bfs人,人能在某地当且仅当所到时间小于火到达时间代码#include#i...
阅读全文
摘要:#include#include#include#includeusing namespace std;list p;int ii, jj;bool op(int x) /*这个很重要*/{ return x > n) { ...
阅读全文
摘要:目录stringstring的常见构造函数string与char *(或const char*)之间的转换string 转化为const char*const char* 转化为string string 转化为 char*char* 转化为stri...
阅读全文
摘要:#include#include#includeusing namespace std;templateclass Data{ private: T value; public: Data():value(0...
阅读全文
摘要:题目链接#include#includeusing namespace std;int main(){ int n; cin >> n; ...
阅读全文
摘要:生成1~n的排列:#includeusing namespace std;void print_permutation(int n, int *A, int cur) /*n代表这个排列中的元素数*/{ if(cur == n) ...
阅读全文
摘要:关于构造函数的调用次序,见下列代码 当然了,首先调用基类的构造函数是不容置疑的,不管它在哪里,记住即可,不过关于对象成员的构造函数的调用还需注意, 见 L1, L2, L3, 它们的构造函数的调用次序与它们在此的相对次序有关,如类A排在第一行,因此先调用关于它的对象,这里还应再注意一点,尽管先定义了
阅读全文
摘要:ACM算法模板 · 一些常用的算法模板-模板合集(打比赛专用)
阅读全文
摘要:[C++::STL]之set的用法c++ set求差集,并集,交集
阅读全文
摘要:int ans = 0;void merges(int *a, int lef, int righ){ if(lef == righ) /*边界*/ return ; int mid = lef + (righ -...
阅读全文
摘要:1.一般筛法求素数+快速线性筛法求素数(点击左方)
阅读全文
摘要:知识点链接:http://www.cplusplus.com/reference/string/string/substr/注意:std::string str2 = str.substr (pos,len); /*从下标为pos处找出长...
阅读全文

浙公网安备 33010602011771号