随笔分类 -  STL

摘要:What Are You Talking AboutTime Limit: 10000/5000 MS (Java/Others)Memory Limit: 102400/204800 K (Java/Others)Total Submission(s): 7433Accepted Submission(s): 2298Problem DescriptionIgnatius is so lucky that he met a Martian yesterday. But he didn't know the language the Martians use. The Martian 阅读全文
posted @ 2012-08-10 19:55 加拿大小哥哥
摘要://组数:卡塔南公式 //大致题意:输出所有可能出战顺序 #include #include #include using namespace std; bool is_ok(int *a,int n){ int i,j,k=0; stack s; for(i=1;i>T; while(T--) { cin>>n; for(i=0;i<n;i++) a[i] = i+1; do { if(is_ok(a,n)) ... 阅读全文
posted @ 2012-08-09 17:01 加拿大小哥哥
摘要://Huffman树的构造就不赘述了,使用优先队列每次选择队头的两个数并将其出列,相加后将结果放入队列中,直到队列为空为止.#include <iostream>#include <queue>#include <vector>#include <string>#include <iomanip>#include <algorithm>using namespace std;int main(){ int i,j,k; string s; while(1)//cin遇到空格结束 { getline(cin,s); if(s 阅读全文
posted @ 2012-08-08 19:42 加拿大小哥哥
摘要:/*有一个农夫要把一个木板钜成几块给定长度的小木板,每次锯都要收取一定费用,这个费用就是当前锯的这个木版的长度给定各个要求的小木板的长度,及小木板的个数n,求最小费用38 8 5为例:长度为 21 的木板,截成13和8花费 21再从长度为13的木板上锯下长度为5的木板,花费13 共21+13 =34*/#include <iostream>#include <queue>#include <vector>using namespace std;int main(){ int i,j,k,T; __int64 num,sum=0; while(cin>& 阅读全文
posted @ 2012-08-08 16:25 加拿大小哥哥
摘要:#include <iostream>#include <string>#include <map>#include <iterator>#include <cstdio>using namespace std;int main(){ string s; int cnt=0; map<string,int> tree;//一对一映射 while(getline(cin,s)) { tree[s]++;//数组方式 cnt++; } map<string,int>::iterator iter; for(iter 阅读全文
posted @ 2012-08-07 23:44 加拿大小哥哥
摘要://由先中序建树,然后后序遍历 #include <cstring>#include <string>#include <iostream>#include <cstdlib>using namespace std;typedef struct Node{ char data; Node *lchild,*rchild;}Node,*Bitree;Bitree creat(string s1,string s2){ if(s1.length()==0)//到叶子节点 return NULL; Node *root = new Node; if(! 阅读全文
posted @ 2012-08-07 13:19 加拿大小哥哥
摘要:1.string str[]={"Alex","John","Robert"};// creates vector with 10 elements, // and assign value 0 for each vector<int> v3(10,0);vector<string> v4(str+0,str+3); vector<string>::iterator sIt = v4.begin(); while ( sIt != v4.end() ) cout << *sIt++ &l 阅读全文
posted @ 2012-08-05 15:25 加拿大小哥哥
摘要:RailsTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 18846Accepted: 7515DescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish 阅读全文
posted @ 2012-08-02 17:51 加拿大小哥哥