摘要: L2-032 彩虹瓶 (25 分) L2-032 彩虹瓶 (25 分) L2-032 彩虹瓶 (25 分) 彩虹瓶的制作过程(并不)是这样的:先把一大批空瓶铺放在装填场地上,然后按照一定的顺序将每种颜色的小球均匀撒到这批瓶子里。 假设彩虹瓶里要按顺序装 N 种颜色的小球(不妨将顺序就编号为 1 到 阅读全文
posted @ 2019-03-31 10:35 Coodyzのblog 阅读(2026) 评论(0) 推荐(2) 编辑
摘要: L2-019 悄悄关注 (25 分) L2-019 悄悄关注 (25 分) L2-019 悄悄关注 (25 分) 新浪微博上有个“悄悄关注”,一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注的人发表的微博给该用户。现在我们来做一回网络侦探,根据某人的关注列表和其对其他用户的 阅读全文
posted @ 2019-03-27 16:28 Coodyzのblog 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: 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) 编辑
摘要: 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) 编辑
摘要: #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) 编辑