
poj
文章平均质量分 57
diarymaggie
这个作者很懒,什么都没留下…
展开
-
[poj]2789:计算图像方差
如果按照公式直接计算,会超时 这里有2个技巧:1、利用积分图像 2、方差的公式变换 s^2=1/n[(x1^2+x2^2+...+xn^2)-nx'] 代码如下,但是不知道为什么总是WA,实在是找不到问题所在 #include #include #include #include #include using namespace std; double calVar(vector >&原创 2013-05-15 13:22:52 · 279 阅读 · 0 评论 -
[poj]2785:武林
这是一道典型的模拟题 设置两个数据结构,一个用来保存每个门派的人的状态,一个用来模拟武林战斗 #include #include #include #include #include using namespace std; struct Attri { int rowNo; int colNo; int innerPower; int kongfu; int live; in原创 2013-05-16 13:31:24 · 292 阅读 · 0 评论 -
[poj]2783:Holiday Hotel
A candidate hotel M meets two requirements: Any hotel which is closer to the seashore than M will be more expensive than M. Any hotel which is cheaper than M will be farther away from the se原创 2013-05-15 10:55:05 · 401 阅读 · 0 评论 -
[poj]2786:Pell数列
Pell数列a1, a2, a3, ...的定义是这样的,a1 = 1, a2 = 2, ... , an = 2 * an − 1 + an - 2 (n > 2)。 给出一个正整数k,要求Pell数列的第k项模上32767是多少。 主要是求模运算,思路类似斐波那契数列计算 #include int main() { int N; scanf("%d"原创 2013-05-15 11:07:05 · 301 阅读 · 0 评论 -
[poj]2788:二叉树
由正整数1,2,3……组成了一颗二叉树。我们已知这个二叉树的最后一个结点是n。现在的问题是,结点m所在的子树中一共包括多少个结点。 这题如果采用递归,会超时 如果采用队列遍历每一层,会超内存 思路还是遍历每一层,计算出这一层的结点数,设置两个变量保存每一层的最大结点值和最小结点值 时间复杂度是O(logN) #include int main() { int M,N; whil原创 2013-05-15 11:52:52 · 298 阅读 · 0 评论