摘要: 1 int search(int t) 2 { 3 if(满足输出条件) 4 { 5 输出解; 6 } 7 else 8 { 9 for(int i=1;i<=尝试方法数;i++) 10 if(满足进一步搜索条件) 11 { 12 ... 阅读全文
posted @ 2019-03-25 21:49 Coodyzのblog 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define OVERFLOW 3 9 using namespace std; 10 typedef char TElemType; 11 TElemType ch; 12 typedef st... 阅读全文
posted @ 2019-03-25 21:46 Coodyzのblog 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序算法主要是循环执行以下两步,直到不存在入度为0的顶点为止。 (1) 选择一个入度为0的顶点并输出之; (2) 从网中删除此顶点及所有出边。 循环结束后,若输出的顶点数小于网中的顶点数,则输出“有回路”信息,否则输出的顶点序列就是一种拓扑序列。 输入 第一行输入两个整数n和m,n表示途中节点数,m表示途中边数;接下来输入m行,每一行有两个整数v1和v2,v1和v... 阅读全文
posted @ 2019-03-25 21:43 Coodyzのblog 阅读(175) 评论(0) 推荐(0) 编辑
摘要: int gys(int m, int n){ return n == 0 ? m : gys(n, m % n); } 阅读全文
posted @ 2019-03-25 21:42 Coodyzのblog 阅读(625) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; void Prim(int list[],int n) { int num=1,a=0,b=0; for(int i=n;i>0;i--) num*=i; while(num--) { for(int i=0;i0;--i){ if... 阅读全文
posted @ 2019-03-25 21:41 Coodyzのblog 阅读(125) 评论(0) 推荐(0) 编辑
摘要: int find(int x){ if(x==pre[x]) return x; return pre[x]=find(pre[x]); } void unite(int x,int y){ x=find(x); y=find(y); if(x!=y) pre[x]=y; } void is_connect(){//if cnt == 1 :连通集 ... 阅读全文
posted @ 2019-03-25 21:39 Coodyzのblog 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 priority_queue, cmp > q2; 2 struct cmp{ 3 bool operator () (const int &a, const int &b){ 4 return a>b; 5 } 6 }; 7 8 9 10 #include 11 using namespace std; 12 13 struct... 阅读全文
posted @ 2019-03-25 21:39 Coodyzのblog 阅读(107) 评论(0) 推荐(0) 编辑
摘要: #include <iomanip> cout<<setw(9)<<left<<a<<"#"<<endl;//占位9个字符 ~~~ 左对齐 cout<<setiosflags(ios::fixed)<<setprecision(2)<<a; // ~~~ 保留两位小数 阅读全文
posted @ 2019-03-25 21:38 Coodyzのblog 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 const int INF = 100000000; 5 const int maxn = 10000; 6 typedef pair P; //储存坐标下x,y 7 int maze[maxn][maxn]; 8 int d[maxn][maxn]; //储... 阅读全文
posted @ 2019-03-25 21:36 Coodyzのblog 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 例:hnitoj_1490 阅读全文
posted @ 2019-03-25 21:34 Coodyzのblog 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 巴什博弈: 一堆物品,规定每次取物品的个数是[1,m],最后取尽物体的一方赢。 策略分析:如果n=m+1,那么由于一次最多取m个物品,所以无论先取者拿走多少, 后取者都能一次性拿走剩余的物品,后者取胜。因此我们发现取胜的法则是: 如果n=(m+1)*r+s (r为任意自然数,s<=m),那么先取者要 阅读全文
posted @ 2019-03-25 21:33 Coodyzのblog 阅读(332) 评论(0) 推荐(0) 编辑