- 博客(20)
- 资源 (2)
- 收藏
- 关注
原创 最小树-图的最短路径
#include #include #define INF 1000000using namespace std;bool visited[200] = {false};int dist[200];int graph[200][200];int Dijkstra(int, int, int);int Prim(int a, int v){ int min_, s, ans; /
2014-12-28 15:32:41 324
原创 图的最短路径
1000. 畅通工程 Total:159Accepted:26 Time Limit: 1sec Memory Limit:256MB Description 本周练习是最后一次练习...前面每一周的练习都已经重新开放...不
2014-12-28 15:28:14 228
转载 sicily 1022---可用于大数据排序查找中位数(非常快)--优先队列
#include #include #include #include #include #include using namespace std;struct Student{char name_[15];int solve;} stu;struct Greater{bool operator() (Student a,
2014-12-26 00:18:22 318
转载 make_heap();、pop_heap();、push_heap();、sort_heap();
STL里面的堆操作一般用到的只有4个:make_heap();、pop_heap();、push_heap();、sort_heap();他们的头文件函数是#include 首先是make_heap();他的函数原型是:void make_heap(first_pointer,end_pointer,compare_function);一个参数是数组或向量的头指针,
2014-12-25 23:08:14 247
转载 priority_queue的用法
priority_queue的用法priority_queue调用 STL里面的 make_heap(), pop_heap(), push_heap() 算法实现,也算是堆的另外一种形式。先写一个用 STL 里面堆算法实现的与真正的STL里面的 priority_queue用法相似的priority_queue, 以加深对 priority_queue 的理解
2014-12-25 22:51:34 154
原创 1018. A Card Trick
#include #include #include #include #define n 5using namespace std;struct Card{ string str; char color; char value; int order; int col_order;} card[100];bool cmp(Card a, Card b){ if
2014-12-24 15:26:12 165
原创 Huffman Coding
Description美国数学家David Huffman在1952年发明了赫夫曼编码,在编码中用到的特殊的二叉树称为Huffman tree。给出n个字符在文本中的出现次数,输出文本的Huffman编码长度(即编码后的二进制序列有多少位)。例如,5个字符出现的次数如下,采用对应Huffman编码可得到最优编码长度为4×5+3×15+1×40+2×30+4×10=205。
2014-12-22 20:49:30 471
原创 1014. Specialized Four-Dig
1014. Specialized Four-DigConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionFind and list all four-digit numbers in decimal notation that have the property that the sum of its fo
2014-12-17 13:45:26 172
原创 sicily1013. Going Home
1013. Going HomeConstraintsTime Limit: 10 secs, Memory Limit: 32 MB Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step,
2014-12-16 23:54:57 193
转载 sicily1935 树的重建(已知树的先序遍历和中序遍历输出树的广度优先遍历)
1935. 二叉树重建ConstraintsTime Limit: 1 secs, Memory Limit: 32 MB Description对于二叉树T,可以递归定义它的先序遍历、中序遍历和后序遍历如下: PreOrder(T)=T的根节点+PreOrder(T的左子树)+PreOrder(T的右子树) InOrder(T)=InOrder(T的左子树)+T的根节点+
2014-12-14 21:24:36 418
转载 二分匹配
#include #include const int MAXN=510;int uN,vN;//u,v数目int g[MAXN][MAXN];int yM[MAXN];int m[MAXN][MAXN];bool used[MAXN];int xM[MAXN];bool dfs(int u)//从左边开始找增广路径{ int v; for(v = 0; v
2014-12-13 13:14:17 125
转载 KM算法最大和最小匹配
//KM算法最大和最小匹配#include #include #include #define Mx 101;using namespace std;int n,result,d;int w[101][101],kmx[101],kmy[101];bool _usex[101],_usey[101];int linky[101];bool find( int i ){
2014-12-13 13:12:36 554
原创 1012. Stacking Cylinders
1012. Stacking CylindersConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionCylinders (e.g. oil drums) (of radius 1 foot) are stacked in a rectangular bin. Each cylinder on an uppe
2014-12-08 13:51:22 215
原创 sicily 1011. Lenny's Lucky Lotto
1011. Lenny's Lucky LottoConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionLenny likes to play the game of lotto. In the lotto game, he picks a list ofN unique numbers in the r
2014-12-07 19:20:53 252
原创 1010. Zipper
1010. ZipperConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the
2014-12-04 23:36:36 155
原创 1009. Mersenne Composite N
1009. Mersenne Composite NConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionOne of the world-wide cooperative computing tasks is the "Grand Internet Mersenne Prime Search" -- GIM
2014-12-04 21:19:01 180
原创 1007 TO and Fro
1007. To and FroConstraintsTime Limit: 1 secs, Memory Limit: 32 MB DescriptionMo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and
2014-12-04 10:36:48 171
原创 用堆排序实现线性时间查找前K大数字
1004. 寻找前k大的数(选做) Total:339Accepted:44 Time Limit: 1sec Memory Limit:256MB Description选做你的任务是写一个程序来找出N个整数里面前K
2014-12-03 09:30:00 736
转载 高精度乘法
#include #include #include #define MAXLEN 200//设置数的最大长度 int main(){ int a[MAXLEN+10], b[MAXLEN+10], len1, len2, c[2*MAXLEN+10], i, j; char str1[MAXLEN + 10], str2[MAXLEN + 10]; for(i = 0;i <
2014-12-02 14:32:47 182
原创 堆排序
/*堆排序思想:先创建堆,然后就把首数字放到未排好数字的最末尾,在调整堆*/#include #include using namespace std;//调整堆void HeapAdjust(int *a, int ¤t, int low, int high){ int large; large = 2 * low + 1; //左儿子 while (large <= h
2014-12-01 23:45:40 194
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人