POJ 1472 自己对于这道题目的理解 主要参考的代码链接 传送门BEGIN LOOP n OP 4 LOOP 3 LOOP n OP 1 END OP 2 END OP 1 END OP 17 OP 17 LOOP n OP 4 LOOP 3 LOOP n ...
c++中vector的拷贝构造过程 c++ 中std::vector的拷贝构造过程 文章来自阿里校招的一道面试题目,向vector中push n个对象,问对象的构造函数,拷贝构造函数,析构函数分别调用了几次?vector中的内存分配策略vector的底层是用动态数组来存储的,当我们用vector<T> vect 这样的形式声明的时候,数组的长度是0,当我们插入第一个元素的时候,数组的长度会变为1,当插...
POJ 2479 很好的思路,同时从前面和后面计算最大的连续序列和,然后遍历中间点,得出最大值。#include<stdio.h>#include<iostream>#include<algorithm>#include<functional>#include<vector>#include<string.h>using nam...
POJ 4044 #include<stdio.h>#include<iostream>#include<algorithm>#include<functional>#include<vector>#include<string.h>using namespace std;vector<int> vect1;vect
CPP 字符串工具类 c++字符串常用操作字符串转化为整形int string_to_int(string s){ return atoi(s.c_str());}整形转化为字符串string tostring(int a){ stringstream ss; ss&lt;&lt;a; return ss.str();}字符转化为字符串st...
POJ 1094 Thinking in topological sorthow to judge if has a loopwhen there are still some unvisited node, but the number of node whose in-degree==0 equals zero, we can say: there is a loop in the graph.ho...
POJ 3026 #include <iostream>#include <algorithm>#include <vector>#include <map>#include <string>#include <queue>#include <cstring>#include <cstdio>
scanf 返回值的总结 返回值代表的是正确匹配的参数个数如果只读到一个EOF,则返回值为EOFint a;while(scanf("%d", &a)==EOF)break;int a;while(~scanf("%d", &a))都可以代表如果数据读取完成,跳出循环。...
CCF CSP 游戏 这道题目让我更加理解BFS对于求最短路径的重要性,如果需要多次访问一个节点,可以在再添加一个维度。#include &lt;iostream&gt;#include &lt;algorithm&gt;#include &lt;vector&gt;#include &lt;map&gt;#include &lt;string&gt;#in
CCF CSP 地铁修建 #include <iostream>#include <algorithm>#include <vector>#include <map>#include <string>#include <queue>#include <cstring>using namespace std;const in
CCF CSP 通信网络 传递闭包问题(a-&gt;b&amp;&amp;b-&gt;c)---&gt;(a-&gt;c)floyd这样做是超时的。#include &lt;iostream&gt;#include &lt;math.h&gt;#include &lt;string.h&gt;#include &
CCF CSP 交通规划 吐槽: CCF绝对是最垃圾的OJ,没有之一,我内存超了,从错误类型中没看出来…..为了防止内存超了,利用临接链表为了防止时间超了,利用优先队列,其他的比较简答了。#include <iostream>#include <math.h>#include <string.h>#include <stdio.h>#includ...
Floyd算法的一点思考 Floyd算法是解决任意两点最短路径的经典DP算法。状态方程假设i~ji~ji\text{~}j的最短路径经过中间结点kkk,则δ(i,j)=δ(i,k)+δ(k,j)δ(i,j)=δ(i,k)+δ(k,j)\delta(i,j)=\delta(i, k)+\delta(k, j) 我们令算法的状态转移方程为 f(k,i,j)=min(f(k−1,i,j),f(k−1,i,...
CCF CSP 行车路线 #include &lt;iostream&gt;#include &lt;stdio.h&gt;#include &lt;string.h&gt;#include &lt;queue&gt;using namespace std;typedef long long int LL;const LL MAXSIZE = 502;const LL INF = 0x3f3
CCF CSP URL映射 #include <iostream>#include <string>#include <stdlib.h>#include <cstdio>#include <map>#include <vector>using namespace std;map<string, string> dict;ve
POJ 1472 #include &amp;lt;iostream&amp;gt;#include &amp;lt;cstdio&amp;gt;#include &amp;lt;string&amp;gt;#include &amp;lt;sstream&amp;gt;#include &amp;lt;cstring&amp;gt;using names
POJ 2965 自己简答的实现了一个队列 * 当push操作的时候,tail++ * 当pop操作的时候,head++暂时没有考虑队列满和空的情况#include <iostream>#include <string.h>using namespace std;int visit[1<<16];int pre[1<<16];int Q[1&...
POJ 1753 #include <iostream>#include <queue>using namespace std;int visit[1<<16+10];queue<int > Q;int getnext(int temp, int x, int y){ temp ^= 1<<(4*x+y); if (x-1>...
Float Vs Double visual IEEEmake use of the property of union keyword#include <stdio.h>union FloatingPointIEEE754 { struct { unsigned int mantissa : 23; unsigned int exponent : 8; ...