随笔分类 - Algorithom
大一写的一些算法题
摘要:【转载】只为让价值共享,如有侵权敬请见谅! 一、哈夫曼树的概念和定义 什么是哈夫曼树? 让我们先举一个例子。 判定树: 在很多问题的处理过程中,需要进行大量的条件判断,这些判断结构的设计直接影响着程序的执行效率。例如,编制一个程序,将百分制转换成五个等级输出。大家可能认为这个程序很简单,并且很快就可
阅读全文
摘要:http://poj.org/problem?id=2681 给你任意长度的字符串,找出两串字符中不相同的字符个数(总数)
阅读全文
摘要:http://poj.org/problem?id=1562
阅读全文
摘要:Description You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you
阅读全文
摘要:题目描述: 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。 任务描述: 给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列
阅读全文
摘要:http://poj.org/problem?id=1456
阅读全文
摘要:C++通过以下几个类支持文件的输入输出 (1) ofstream:写操作,输出文件类; (2) ifstream:读操作,输入文件类; (3) fstream:可同时读写的文件类。 1. open函数:打开文件 函数原型:void open(const char*filename,int mode,
阅读全文
摘要:题意:给出一个矩阵,其中有些格子干燥、有些潮湿。 如果一个潮湿的格子的相邻的四个方向有格子也是潮湿的,那么它们就可以构成更大 的湖泊,求最大的湖泊。 也就是求出最大的连在一块儿的潮湿的格子的数目。
阅读全文
摘要:#include #include using namespace std; int n,k,bb[8]={0},sum=0; char aa[8][8]; void dfs(int a,int b) { if(b>=n) { if(a==k) sum++; return; } for(int i=0...
阅读全文
摘要:http://poj.org/problem?id=1088
阅读全文
摘要:http://poj.org/problem?id=1154
阅读全文
摘要:初学dfs参考别人代码,如有雷同,见怪不怪。#include using namespace std; int aa[25][25]; int maxa=0; int step[25]={0},n; void dfs(int a,int b) { int t=b; step[a]=1; for(int i=0;i>n; for(int i=0;i>aa[i][j]; ...
阅读全文
摘要:http://poj.org/problem?id=3664 进行两轮选举,第一轮选前n进入第二轮,第二轮选最高
阅读全文
摘要:Description n participants of << crazy tea party >> sit around the table. Each minute one pair of neighbors can change their places. Find the minimum
阅读全文
摘要:http://poj.org/problem?id=2299
阅读全文
摘要:题目:http://poj.org/problem?id=1804 大意:给你一串数字,排序。求出最少的交换次数 \ 我用归并做的
阅读全文
摘要:题目链接:http://poj.org/problem?id=1979
阅读全文
摘要:题目链接:http://poj.org/problem?id=2739
阅读全文
摘要:题目链接:http://poj.org/problem?id=1331 主要介绍strtol函数:
阅读全文
摘要:Description Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this p
阅读全文