04 2016 档案
摘要:///继承与派生 #include <iostream> using namespace std; class Point { public: Point (float a=0,float b=0):x(a),y(b) {} ///有默认参数的构造函数 void setPoint (float,fl
阅读全文
摘要:///友元 ///友元有利于数据共享,但是破坏了类的封装性 #include <iostream> using namespace std; class Time { public: Time (int h=10,int m=10,int s=10):hour(h),minute(m),sec(s)
阅读全文
摘要:///对象指针 #include <iostream> using namespace std; class Time { public: Time(int h=10,int m=10,int s=10):hour(h),minute(m),sec(s) {} int hour; int minut
阅读全文
摘要:///简单的使用类和对象 #include <iostream> using namespace std; ///构造函数的重载,求体积 class Box { public: Box(); ///不带参数的构造函数,来初始化 Box(int h,int w,int l):height(h),wid
阅读全文
摘要:小草的C++要结课了,小草终于翻起书来,小草用的老谭的书,有什么不对的就找老谭去吧。 ///C++初步 ///C++对C的扩展 #include <iostream> using namespace std; ///const定义常量 const int inf=0x3f3f3f3f; int ma
阅读全文
摘要:题目链接:http://poj.org/problem?id=1363 #include <stdio.h> #include <stack> using namespace std; int ans[10000]; ///出栈秩序 int main() { int t; ///有多少车厢 whil
阅读全文
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151 这里可以用栈模拟,也可以用STL,reverse();函数。 但是我这里用栈模拟,PE了,了解一下这个做法吧。 #include <cstdio> #include
阅读全文
摘要:题目链接:http://poj.org/problem?id=1028 注意: 1、用两个栈来模拟,一个用来存可以返回的,一个用来存可以前进的。 2、visit方法,就要将可以前进的栈清空。 3、back方法,将当前的网页给可以前进的栈,而可以返回的栈出栈一个元素。 4、forward方法,将当前网
阅读全文
摘要:题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit per test 256 megabytes input standard input output
阅读全文
摘要:题目链接:http://codeforces.com/contest/664/problem/A A. Complicated GCD time limit per test 1 second memory limit per test 256 megabytes input standard in
阅读全文
摘要:#include <stdio.h> #include <string.h> #include <queue> using namespace std; #define MAXN 1005 struct node { int x; int y; int step; }; char maps[MAXN
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1195 解题报告: #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; s
阅读全文
摘要:题目链接:http://poj.org/problem?id=3083 解题报告:这个题目,搜最短路,没有什么问题。优先走左边,走右边,有很多说法,思路大概都相同,都是记录当前朝向,根据数学公式(i+j+3)%4计算下一个方向,但是小草发现有些博客里面有一点点小错误,就是在方向的表示上。 左边优先,
阅读全文
摘要:题目链接:http://poj.org/problem?id=2665 解题报告: 这里的区域没有重复,若有重复的话,模拟即可。
阅读全文
摘要:题目链接:http://poj.org/problem?id=1995 参考:http://www.cnblogs.com/PegasusWang/archive/2013/03/13/2958150.html 解题报告: #include <iostream> #include <stdio.h>
阅读全文
摘要:题目链接:http://poj.org/problem?id=3536 在体积固定的情况下,表面积最小时的长,宽,高。 这里枚举长,宽,根据体积计算高。 #include <iostream> #include <algorithm> using namespace std; int x=0,y=0
阅读全文
摘要:题目链接:http://poj.org/problem?id=3126 解题报告: #include <iostream> #include <queue> #include <stdio.h> #include <string.h> using namespace std; #define MAX
阅读全文
摘要:题目链接:http://poj.org/problem?id=2049 解题报告: 网格中的BFS,最主要的是边界问题。 1、这里在左右,上下两个方向上,分别判断墙,和门,细节是,向上有t个墙,for(int j=0;j<t;j++) ya[x][y+1+j]=WALL; ymax=max(y+t+
阅读全文
摘要:题目链接:http://poj.org/problem?id=3505 解题报告: #include <stdio.h> #include <iostream> #include <math.h> #include <algorithm> using namespace std; #define M
阅读全文
摘要:题目链接:http://poj.org/problem?id=3187 解题报告: #include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { int n,sum; sca
阅读全文
摘要:题目链接:http://poj.org/problem?id=2006 解题报告: 题意看了半天,没看懂,再加上化学没学好,更加让我头痛。 假设1L溶解了x摩尔的酸:ka=m*x*nx/ori-x; 得:mnx*x+kax-ka*ori=0; 解方程x=(sqrt(k*k*a*a+4mnka*ori
阅读全文
摘要:题目链接:http://poj.org/problem?id=2485 #include <iostream> #include <stdio.h> #include <memory.h> #include <string.h> #include <stdlib.h> using namespace
阅读全文
摘要:Kruskal算法是根据权来筛选节点,也是采用贪心算法。 /// Kruskal ///初始化每个节点为独立的点,他的祖先为自己本身 void made(int n) { for(int i=0; i<=n; i++) father[i]=i; ///father[i]存的父亲的编号 } ///找x
阅读全文
摘要:题目链接:http://poj.org/problem?id=1258 解题报告:
阅读全文
摘要:题目链接:http://poj.org/problem?id=2485 解题报告: 这里有一点要注意的是,第一个点时,dis数组还没有初始化,还全部为inf。第一次来到更新权时,才把邻接矩阵的数据存到dis中。
阅读全文
摘要:Prim算法,代码核心在于一个双重循环,所以算法时间复杂度为O(n*n)。 该算法与图中的边数无关。 适用于计算边稠密的最小生成树。 Prim算法采用贪心,不同于Kruskal算法的地方是,Prim算法筛选节点,找到下一条权最小的路。而Kruskal算法筛选权,来连接节点。 /// Prim boo
阅读全文
摘要:题目链接:http://poj.org/problem?id=1018 这个DP,我的头都快晕了。 dp[i][j]表示取到第i个设备,宽带为j时的最小价格。 状态转移方程: dp[i][k]=min(dp[i][k],dp[i-1][k]+p) 输出结果: for(int i=0;i<=1100;
阅读全文
摘要:题目链接:http://poj.org/problem?id=2385 题意: 牛在两棵苹果树下收集苹果,牛只能在这两棵树之间走动w次,在t时刻,某棵树会掉下苹果。 解题报告:
阅读全文
摘要:题目链接:http://poj.org/problem?id=2250 解题报告: 1、状态转移方程: 2、记录决策 3、反序输出
阅读全文
摘要:题目链接:http://poj.org/problem?id=2192 解题报告: 1、类似最长公共子序列,dp[i][j]表示用s1前i个字符和s2前j个字符来构成目标单词的一部分,是否成功 2、状态转移方程:
阅读全文
摘要:题目链接:http://poj.org/problem?id=3669 解题报告: 1、流星坠落的点,四周和自己本身都被毁灭,不断更新每个点被毁灭的时候的最短时间。 2、搜索终点是,到达某个点,这个不会有流星毁灭他,即他的毁灭的时间大于最后一个流星到达时的时间。
阅读全文
摘要:题目链接:http://poj.org/problem?id=3414 解题报告: 1、每个节点都是一个独立的状态 2、这里的状态转移就是有几种出路,4种:1、倒掉a中的水,2、把a中的水倒到b中去,3、倒掉b 中的水,4、把b中的水倒到a中去 3、每次的步骤记录到str[][]中去 4、搜索最短路
阅读全文
摘要:题目链接:http://poj.org/problem?id=2109 double 可以虽然可以表示10^-307~~~10^208,但是精确度只有16位,这个题有bug。
阅读全文
摘要:题目链接:http://poj.org/problem?id=3278
阅读全文
摘要:题目链接:http://poj.org/problem?id=2251 参考了一下大神们的解法。也有用深搜的。然而,之前不久看到一句话,最短路径——BFS。 参考:http://blog.csdn.net/lyy289065406/article/details/6647938
阅读全文
摘要:题目链接:http://poj.org/problem?id=1129 解题报告:
阅读全文
摘要:题目链接:http://codeforces.com/contest/404/problem/B 也可以用浮点数取模函数fmod(a,b);
阅读全文
摘要:题目链接:http://codeforces.com/contest/404/problem/A
阅读全文
摘要:题目链接:http://poj.org/problem?id=1011 解题报告:
阅读全文
摘要:题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=171 解题报告: 1、按照体重排序 2、成绩过了分数线,就加入 3、剩下没有安排的人,加入到各个区域,确保各个区域招满
阅读全文
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1315 解题报告:
阅读全文
摘要:题目链接:http://poj.org/problem?id=1017 解题报告:
阅读全文
摘要:题目链接:http://poj.org/problem?id=2709 解题报告:
阅读全文
摘要:题目链接:http://poj.org/problem?id=1328 解题报告: 1、按照头结点排序。 2、按照尾节点排序。
阅读全文
摘要:Codeforces Round #309 (Div. 1) A. Kyoya and Colored Balls time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu
阅读全文