自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

学习为主,偶尔扯淡

爱,之于我,不是肌肤之亲,不是一蔬一饭,它是一种不死的欲望,是疲惫生活中的英雄梦想

  • 博客(80)
  • 收藏
  • 关注

原创 1082 Read Number in Chinese (25 分)

A1082#include <cstdio>#include<cstring>int main() { char num[][10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"

2019-02-28 11:17:47 270

原创 1076 Forwards on Weibo (30 分)

#include<cstdio>#include<algorithm>#include<queue>#include<cstring>using namespace std;const int maxn=1010;int N, L;int inque[maxn];struct Node{ int layer; vector&lt...

2019-02-27 17:32:59 298

原创 1146 Topological Order (25 分)

A1146#include<cstdio>#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn=1010;int N, M, K;vector<int>G[maxn];int indegree[m...

2019-02-27 11:26:04 259

原创 1013 Battle Over Cities (25 分)

A1013考点:连通集的个数#include<cstdio>#include<vector>#include<cstring>using namespace std;const int maxn=1010;const int INF=1000000000;int N, M, K;int d[maxn][maxn], visit[maxn]...

2019-02-25 14:49:22 452

原创 1099 Build A Binary Search Tree (30 point(s))

A1099#include<cstdio> #include<algorithm>#include<queue>using namespace std;const int maxn=1010;int in[maxn];int N;struct Node{ int left, right; int key;}p[maxn];int in...

2019-02-25 09:45:19 140

原创 1087 All Roads Lead to Rome (30 point(s))

A1087#include<cstdio>#include<string>#include<map>#include<iostream>using namespace std;const int maxn=1010;const int INF=1000000000;int N, K;map<string, int>s...

2019-02-23 21:50:09 288 2

原创 1018 Public Bike Management (30 point(s))

A1018#include<cstdio>#include<iostream>#include<vector>#include<cmath>using namespace std;const int maxn=1010;const int INF=0x3fffffff;int C, N, S, M;int G[maxn][max...

2019-02-23 14:21:58 187

原创 1098 Insertion or Heap Sort (25 point(s))

解法一:#include<cstdio>#include<algorithm>using namespace std;const int maxn=1010;int N;int start[maxn], target[maxn];void adjust(int low, int high, int A[]){ int i=low, j=i*2; whi...

2019-02-21 13:40:45 108

原创 1075 PAT Judge (25 point(s))

The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file co...

2019-02-10 15:10:18 142

原创 1031 Hello World for U (20 point(s))

Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be prin...

2019-01-22 17:02:03 171

原创 1010 一元多项式求导 (25 point(s))

设计函数求一元多项式的导数。(注:x​n​​(n为整数)的一阶导数为nx​n−1​​。)输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过 1000 的整数)。数字间以空格分隔。输出格式:以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。注意“零多项式”的指数和系数都是 0,但是表示为 0 0。输入样例:3 4 ...

2019-01-07 17:27:34 260

原创 08-图7 公路村村通 (30 分)

修路成本最低(贪心), 用Prim算法(最小生成树)比较Dijkstra算法和Prim算法#include<cstdio>#define INFINITY 65535using namespace std;const int maxn=1001;int dist[maxn], C[maxn][maxn], parent[maxn];int N, M, cnt...

2018-11-25 16:44:44 920

原创 07-图6 旅游规划 (25 分)

 题目概括:给两个城市点,求这两个点的最短路径,如果有若干条最短路径,则选择最便宜的那条。。显然单源有权图用Dijkstra算法,只不过有多了一重选择条件#include<cstdio>#define INFINITY 65535const int maxn=510;int dist[maxn], cost[maxn], E[maxn][maxn], C[maxn]...

2018-11-25 14:36:41 427

转载 07-图5 Saving James Bond - Hard Version (30 分)

  无权单源图BFS【以下转自xijujie的代码】思路很清晰#include<iostream>#include<cmath>#include<queue>#include<vector>#include<algorithm>using namespace std;const double D=15.0;...

2018-11-24 11:06:24 422

原创 07-图4 哈利·波特的考试 (25 分)

多源有权图——Floyd算法 #include<cstdio>#include<queue>#include<stdlib.h>const int maxn=110;const int INFINITY=65535; struct AEdge{ int v1, v2; int weight;};typedef struct AEdge...

2018-11-23 22:14:22 416

原创 06-图3 六度空间 (30 分)

  这道题,首先要确认的是用 DFS还是BFS,考虑到你要找的人,可能是你朋友的朋友的朋友。。每个人都有自己的交际圈,所以把每个人(结点)的交际圈看成一层,那么只要不超过六层的结点就是符合要求的,因此应用BFS。下图是根据题目要求对BFS进行改造:【以上源自中国mooc大学浙大数据结构姥姥的课件*_*  有些截图我没说(因为懒,但是大家都懂吧。。】#include<cs...

2018-11-22 10:14:24 1239

原创 06-图2 Saving James Bond - Easy Version (25 分)

#include<cstdio>int const maxn=110;int N, D, answer=0;int visit[maxn];struct point{ int x, y;}arr[maxn]; //三种结点 原点、鳄鱼、岸边int Jump(int v, int i){ int flag; int a=arr[i].x-arr[v].x, b...

2018-11-21 11:39:28 158

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋期中考试

判断题1-1 在具有N个结点的单链表中,访问结点和增加结点的时间复杂度分别对应为O(1)和O(N)。 (3分) T1-2 无向连通图至少有一个顶点的度为1。 (3分) F1-3 算法分析的两个主要方面是时间复杂度和空间复杂度的分析。 (2分) T1-4 某二叉树的后序和中序遍历序列正好一样,则该二叉树中的任何结点一定都无右孩子。(3分) T1-5 将1、2、3、4、5、6顺序插...

2018-11-20 11:47:12 6976 4

原创 04-树6 Complete Binary Search Tree (30 分)

#include<cstdio>#include<stdlib.h>const int maxn=1001;int arr[maxn], brr[maxn];int pos=0, n;int cmp(const void *a, const void *b){ return(*(int *)a-*(int *)b);}void solve(int ro...

2018-10-26 20:03:46 492 1

原创 04-树5 Root of AVL Tree (25 分)

 #include<cstdio>#include<stdlib.h>typedef struct TNode* Tree;struct TNode{ int data; Tree Left, Right;};int Height(Tree T){ if(T){ int HL=Height(T->Left); int HR=Heigh...

2018-10-07 16:16:29 1076 1

原创 04-树7 二叉搜索树的操作集 (30 分)

本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST ...

2018-10-05 22:56:21 567

原创 03-树3 Tree Traversals Again (25 分)

 【mooc上姥姥提供的代码】#include<cstdio>#include<stack>#include<string>#include<iostream>using namespace std;const int maxn=100;int pre[maxn], in[maxn], post[maxn];void s...

2018-10-04 23:57:25 1867 1

原创 03-树2 List Leaves (25 分)

大致思路:先找到根结点root(没有任何结点指向它的结点),并且记录叶子的个数,然后运用层序遍历(根据题目要求选的),将叶结点的坐标输出,注意输出格式。#include<cstdio>#include<queue>using namespace std;const int maxn=20;struct TNode{ int left, right;}T...

2018-10-04 22:13:21 571

原创 03-树1 树的同构 (25 分)

这道题不难,画图就出来了#include<cstdio>#define null -1const int maxn=15;typedef int Tree;typedef char ElementType;struct TNode{ Tree left, right; ElementType data; int flag;}T1[maxn], T2[...

2018-10-04 18:29:29 1016

原创 二叉树中序遍历、后序遍历和层序遍历非递归实现

一、中序遍历访问顺序:左子树 -> 结点 -> 右子树难点在于访问左子树后应该怎么回到结点本身或者其右子树呢?这里利用了堆栈来临时存储,需要利用上一个结点时可以pop出来(有种撤回键的感觉2333)。void PreOrderTravel(BinTree BT){ BinTree T = BT; stack<BinTree> st; while(T ||...

2018-10-04 17:04:13 610

原创 02-线性结构2 一元多项式的乘法与加法运算 (20 分)

设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。输入样例:4 3 4 -5 2...

2018-09-27 18:48:59 137

原创 01-复杂度2 Maximum Subsequence Sum(25 分)

Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequen...

2018-09-11 18:26:28 796

原创 1024 Palindromic Number(25 point(s))

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...

2018-08-28 11:21:08 132

原创 1017 A除以B(20 point(s))

本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。输入格式:输入在一行中依次给出 A 和 B,中间以 1 空格分隔。输出格式:在一行中依次输出 Q 和 R,中间以 1 空格分隔。输入样例:123456789050987654321 7输出样例:17636684150...

2018-08-22 09:35:42 293

原创 1059 Prime Factors (25)(25 point(s))

Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1* p2^k2 *…*pm^km.Input Specification:Each input file contains one test case w...

2018-08-22 08:56:09 141

原创 1089 Insert or Merge(25 point(s))

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...

2018-08-17 10:32:17 244

原创 1030 完美数列(25)(25 point(s))

给定一个正整数数列,和正整数,设这个数列中的最大值是,最小值是,如果,则称这个数列是完美数列。现在给定参数和一些正整数,请你从中选择尽可能多的数构成一个完美数列。输入格式:输入第一行给出两个正整数N和p,其中()是输入的正整数的个数,()是给定的参数。第二行给出个正整数,每个数不超过。输出格式:在一行中输出最多可以选择多少个数可以用它们组成一个完美数列。输入样例:10...

2018-08-15 21:05:19 1456

原创 1044 Shopping in Mars (25)(25 point(s))

Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M). When making the payment, the chain can be cut at any position f...

2018-08-15 17:04:57 149

原创 递归——以全排列和n皇后问题举例

笔记来自【晴神宝典】一、递归递归 就在于反复调用自身函数,但是每次都把问题范围缩小,直到范围可以缩小到可以直接得到边界数据的结果,然后在返回路上求出对应的解。以上可看出,递归很适合用来实现分治思想。递归两个很重要的组成组成:1、递归边界(出口);2、递归式。 二、全排列 (Full Permutation)【可画图,便于理解】#include <cstd...

2018-08-12 13:15:33 323

原创 1048 Find Coins (25)(25 point(s))

Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However,...

2018-08-11 19:26:08 322

原创 1039 到底买不买(20)(20 point(s))

小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子;如果不是,那么告诉她缺了多少珠子。为方便起见,我们用[0-9]、[a-z]、[A-Z]范围内的字符来表示颜色。例如在图1中,第3串是小红想做的珠串;那么第1串可以买,因为包含了全部她想要的珠子,...

2018-08-11 15:32:50 106

原创 1084 Broken Keyboard (20)(20 point(s))

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...

2018-08-11 10:58:54 116

原创 1080 Graduate Admission (30)(30 point(s))

It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admissio...

2018-08-11 09:17:43 112

原创 1012 The Best Rank (25)(25 point(s))

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E - Eng...

2018-08-10 11:09:51 188

转载 Segmentation Fault原因总结

转载链接:https://www.cnblogs.com/silence-hust/p/4487026.html最近在项目上遇到了Segmentation Fault的错误,一直调试不出来是哪里出了问题,对于刚接触嵌入式的,也不知道该如何去调试一个项目,定位内存问题,纠结了好几天,好好整理下自己的思路。从头开始。  以下内容只为整理来自己使用的,大多来源于网络,感谢大家的分享:  ht...

2018-08-08 11:37:51 138317

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除