06 2012 档案

POJ 2418 Hardwood Species
摘要:题目地址为http://poj.org/problem?id=2418这题,我起先用的是AVL树,结果时间超时,最后发现,直接用二叉树就行了,根本就不需要旋转。由于数据是随机的,因而这棵二叉树的性能还行。当然还可以用trie树来解决。题目很简单,直接上代码 1 #include <iostream> 2 #include <stack> 3 #include <string.h> 4 #include <stdio.h> 5 #include <stdlib.h> 6 using namespace std; 7 8 class No 阅读全文

posted @ 2012-06-29 13:28 NULL00 阅读(682) 评论(0) 推荐(0)

POJ 1423 Big Number
摘要:Big NumberDescriptionIn many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.InputInput 阅读全文

posted @ 2012-06-28 14:54 NULL00 阅读(1166) 评论(1) 推荐(1)

POJ 1458 Common Subsequence (最长公共子序列)
摘要:Common SubsequenceDescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a subsequence of X if there exists a strictly increasing sequence < i1 阅读全文

posted @ 2012-06-26 13:50 NULL00 阅读(1625) 评论(0) 推荐(1)

POJ 1019 Number Sequence
摘要:Number SequenceDescriptionA single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive integer numbers ranging from 1 to k, written one after another.For example, the fir 阅读全文

posted @ 2012-06-25 14:27 NULL00 阅读(1660) 评论(0) 推荐(0)

POJ 3984 迷宫问题 (Dijkstra)
摘要:迷宫问题Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角的最短路径,格式如样例所示。Sample Input0 1 0 0 00 1 0 1 00 0 0 0 00 1 1 1 00 0 阅读全文

posted @ 2012-06-22 13:57 NULL00 阅读(6572) 评论(1) 推荐(1)

N个鸡蛋放进M个篮子问题
摘要:题目:有N个鸡蛋和M个篮子,把鸡蛋放到M个篮子里,每个篮子都不能为空。另外,需要满足:任意一个小于N的正整数,都能由某几个篮子内蛋的数量相加的和得到。写出程序,使得输入一个(N,M),输出所有可能的分配情况。从题意中应该可以得出,对于(1,1,2,2)和(1,2,1,2)这两种组合,应该是一样的。因而对于这M个篮子中的鸡蛋数量,我们用数组basket[M]来表示,我们按照非递减顺序进行排列,即basket[i] <= basket[i+1]1.我们利用归纳法来总结出一个规律: 对于前n个篮子,其鸡蛋数量总和为Sn,那么对于第n+1个篮子,其鸡蛋数量应该满足: basket[n+1] &l 阅读全文

posted @ 2012-06-20 14:25 NULL00 阅读(6820) 评论(4) 推荐(2)

导航