自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

不忘初心

方得始终

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

原创 PAT 1107 Social Clusters

1107. Social Clusters (30)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a s

2017-02-28 19:46:40 727

原创 PAT 1108 Finding Average

1108. Finding Average (20)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not b

2017-02-28 18:53:27 396

原创 PAT 1109 Group Photo

1109. Group Photo (25)Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:The number of people in each row must be N/K (

2017-02-28 18:06:07 377

原创 PAT 1110 Complete Binary Tree

1110. Complete Binary Tree (25)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first

2017-02-28 15:43:37 329

原创 PAT 1112 Stucked Keyboard

1112. Stucked Keyboard (20)On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen

2017-02-27 19:03:34 310

原创 PAT 1114 Family Property

1114. Family Property (25)This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we

2017-02-26 19:31:40 445

原创 递归,递推,分治,贪心,动态规划......

一.递归:函数调用自身二.递推:由递推公式求解,每个子问题均有确切的解,即每个阶段只有一个状态,静态过程。实现:1.自顶向下,递归,有时遇到重复计算的项,可以先存到外部数组,用到时先判断有没有计算过 2.自底向上,解决掉了存在重复用的项的问题     例子:斐波那契数列三.分治:大问题分解为小问题,再整合成大问题。满足:1) 该问题的规模缩小到一定的程度就可以容易地解决2) 该问题

2017-02-23 19:39:30 1168

原创 PAT 1115 Counting Nodes in a BST

1115. Counting Nodes in a BST (30)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with

2017-02-22 20:14:04 449

原创 PAT 1117 Eddington Number

1117. Eddington Number(25)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum

2017-02-22 13:29:03 422

原创 PAT 1118 Birds in Forest

1118. Birds in Forest (25)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help

2017-02-22 12:26:26 409

原创 PAT 1122 Hamiltonian Cycle

1122. Hamiltonian Cycle (25)时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe "Hamilton cycle problem" is to find

2017-02-22 10:48:39 465

原创 PAT 1121 Damn Single

1121. Damn Single (25)"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.I

2017-02-22 10:45:02 397

原创 PAT 1012 The Best Rank

1012. The Best Rank (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueTo evaluate the performance of our first yea

2017-02-22 10:38:46 400

原创 C++ 常用类

1.string成员函数编辑(constructor)构建字符串对象 (构造函数成员)operator=字符串赋值 (公有成员函数)以下全为公有成员函数迭代器编辑begin返回指向字符串开始处的迭代器

2017-02-22 09:20:59 1163

原创 位运算

其中:and:按位与or:按位或xor:按位异或shl:左移shr:右移

2017-02-19 13:06:42 250

原创 搜索剪枝

2017-02-19 11:54:53 373

原创 学习搜索

搜索的实质(实质具体到两个搜索方法的表现形式)剪枝状态压缩。。。。。。。。。。。。待添加

2017-02-19 11:47:19 546

原创 POJ 1753(用到了状态压缩)

#include #include #include #include using namespace std;int step;int bfs(int start){ queue Queue; int book[65536],last=start; memset(book,0,sizeof(book)); Queue.push(start); book[start]=1;

2017-02-18 21:37:54 505

原创 求无向连通图的割点和割边/桥

代码直接整合了求割点和割边://求无向连通图的割点和割边/桥#include #include #include using namespace std;#define MAXN 1000#define MAXM 10000struct node{ int to; int next;}edge[MAXM];int head[MAXN];int cnt;int n,m;

2017-02-15 22:27:33 982

原创 最小生成树的Kruskal算法

//最小生成树的Kruskal算法//把所有边的信息存储,排序,按照由小到大顺序依次判断边是否能加入生成树,直到够n-1条边//此处并查集(不相交集)用来判断连通性#include #include #include using namespace std;#define MAXN 1000#define MAXM 10000struct node{ int u; int v

2017-02-14 16:25:18 348

原创 建树/图的方法

建树:二叉树:法一:题目按照节点顺序给出树的值和左右子树的编号,可以把信息直接存在结构体数组,不用再建树,不过得找出树根法二:题目按照节点顺序给出树的值和左右子树的编号,先找到树根,再层序建树。建成的树可以是指针型或者数组型(堆的结构)(这里的数组型得是结构体数组,因为要存当前结点在源数据中的编号),具体由数据规模和方便程度决定二叉搜索树:法一:题目给出数据,直接按照二叉树建树

2017-02-14 13:56:20 5384

原创 蓝桥寒假训练2->2013年第四届蓝桥杯国赛

1.猜灯谜A 村的元宵节灯会上有一迷题: 请猜谜 * 请猜谜 = 请边赏灯边猜小明想,一定是每个汉字代表一个数字,不同的汉字代表不同的数字。请你用计算机按小明的思路算一下,然后提交“请猜谜”三个字所代表的整数即可。答案:897法一:逐一枚举所有3位数,分离各位数字,判断与商中相应数字是否相同,且要判断商中十位与万位是否相同#include #incl

2017-02-14 11:35:26 661

原创 蓝桥测试3->寒假训练题集

hehe

2017-02-13 23:06:18 835

原创 Prim算法另一种形式

#include #include #include using namespace std;#define MAXN 10000#define MAXM 1000#define INF 0X7FFFFFFFstruct node{//1 原图 2 生成树 生成树要存起来 int to; int weight; int next;}edge1[MAXM],edge2[MAX

2017-02-12 21:18:17 354

原创 各最短路径算法(图论)比较

2017-02-11 22:28:41 582

原创 Bellman-Ford算法的队列优化

//Bellman-Ford算法的队列优化//有向图 能解决负权 负圈会呈现一定形式,可加入判断,判断是否有负圈#include #include #include using namespace std;#define MAXN 10000#define MAXM 1000#define INF 0X7FFFFFFFstruct node{ int to; int weig

2017-02-11 19:59:28 475

原创 Bellman-Ford算法

//有向图 能解决负权 对于负圈,表现出一定结果#include #include #include using namespace std;#define MAXN 10000#define MAXM 1000#define INF 0X7FFFFFFFstruct node{ int from; int to; int weight; int next;}edge[M

2017-02-11 14:20:34 293

原创 邻接表的数组实现

#include #include #include using namespace std;#define MAXN 100000#define MAXM 10000int u[MAXM],v[MAXM],w[MAXM];//存边的信息int first[MAXN],nextEdge[MAXM];//first存顶点的第一条边 //nextEdge存边的下一条边int n,m;

2017-02-09 21:39:37 538

原创 图的一些基本概念

图的概念比较杂乱,国内各种书籍对一些概念也是各执己见,比如圈和环.......这里旨在按照一个规则了解一些概念,对于与其他书籍材料的不同,还要看情况再定我们讨论的图大多为简单图->没有环和重边环:一个顶点到他自身的边圈:v1=vn的一条路径。对于有向图,路径长度为1的即为一个环(非简单图)。对于无向图,路径长度为1的还是环,不是圈。且对于没有重边的无向图,u,v,u不算做圈,因为(

2017-02-09 10:31:42 2111

原创 蓝桥测试2->2015年第四届蓝桥杯省赛A组

hehe

2017-02-08 19:52:55 1946

原创 蓝桥测试1->2015年第六届蓝桥杯省赛

hehe

2017-02-05 21:20:38 982

原创 动态规划与矩阵快速幂

动态规划的求解有时也可以通过矩阵快速幂优化,详见15蓝桥省赛9题,垒骰子

2017-02-05 14:07:04 460

原创 蓝桥寒假训练1->2013年第四届蓝桥杯省赛

呵呵

2017-02-03 13:58:34 627

原创 几个重要的排列组合定理公式

1.排列的几个定理公式.排列,一般地,从n个不同元素中取出m(m≤n)个元素,按照一定的顺序排成一列,叫做从n个元素中取出m个元素的一个排列(Arrangement)。特别地,当m=n时,这个排列被称作全排列(Permutation)。.n个元素的循环r-排列的个数为上式除以r循环,顾名思义,就是围成一圈,规定一个方向(顺或逆),转一圈形成的为一种。如:若不围一圈,1234

2017-02-01 16:29:17 42000 1

空空如也

空空如也

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

TA关注的人

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