- 博客(15)
- 收藏
- 关注
原创 将带有括号和数字的字符串,形如AB((AB)5AC)2 ((AB)2AC)5的字符串复原
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cstdio> using namespace std; int main() { string s; string s1=""; getline(c...
2018-09-19 15:57:51 226
原创 求联通块个数
在n*m方阵中,与点(i,j)前后左右和斜对角相邻联通,则这一整块都属于联通块。输入n、m,和方阵阵n*m。0表示不连通,其它数字表示联通,求整个方阵联通块数目。 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std...
2018-08-27 15:11:02 902
原创 快速排序
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<cstring> #include<vector> using namespace std; int n; vector<int >a; void qui
2018-08-02 17:41:22 117
原创 用桟实现深度遍历判环
#include<cstdio>#include<iostream>#include<algorithm>#include<queue>#include<stack>#include<cstring>#include<vector>using namespace std;vector<int&
2018-07-02 10:00:24 170
转载 HDU2196
原文链接https://blog.csdn.net/angon823/article/details/52261423dp[u][0]表示在u的子树下u的最远距离是多少dp[u][1]表示在u的子树下(和dp[u][0]不是同一孩子)u的次远距离是多少dp[u][2]表示通过u的父亲能走的最远距离是多少...
2018-04-17 16:40:41 319
转载 http://www.cnblogs.com/jiangjing/archive/2013/01/14/2860163.html
//根据前序和中序遍历写出后序遍历 #include using namespace std; int t1[1001],t2[1001]; void sousuo(int a,int b,int n,int flag) { if(n==1)//如果存在左子树或右子树就直接输出 { printf("%d ",t1[a]); return ;
2016-09-03 22:56:29 872
原创 双向循环链表的建立
#include #include #include using namespace std; struct node { int num; struct node *next,*prior; }; struct node *createlink(int n) { int i; struct node *head,*p,*q; head=(struct
2016-09-02 17:14:24 373
原创 循环链表的建立
#include #include #include using namespace std; struct node { int num; char name[10]; struct node *next; }; struct node *createlink(int n) { int i; struct node *head,
2016-09-02 16:41:04 303
原创 单链表的建立、排序、打印
#include #include #include using namespace std; struct node { int num; char name[10]; struct node *next; }; struct node *createlink(int n) { int i; struct node *head,
2016-09-02 16:39:34 218
转载 hdu5722 Jewelry
转自http://www.cnblogs.com/fzmh/p/5688069.html 题意就是说问有多少个区间,其中有至少一种种类的宝珠出现的次数恰好为x次。 先预处理出每一个位置的宝珠下一个出现与其同种类的宝珠位置next和上一个出现与其同种类的位置pre 考虑在第i个位置的宝珠,要使其出现恰好x次,我们可以找到在i之后恰好出现了x次的位置j,这步操作可以用一定的技巧优化到O(1),那
2016-08-08 01:20:47 281 6
转载 zhangjiangtao BestCoder 2nd Anniversary Wool
#include #include #include #include #include using namespace std; typedef long long LL; const int MAXN = 1e5+5; struct node { LL x, y; } p[MAXN]; bool cmp(node a, node b) { if(a.x == b.x)
2016-07-26 21:56:06 237
转载 hdu5656
求组数的所有不重复子集的最大公约数之和 #include #include using namespace std; long long f[1010],g[1010]; long long ans=0; int t,n,num[1010],a[1010]; long long quick_pow(int a,int x,int p) { long long su
2016-04-05 20:01:23 537
转载 赫夫曼树
#include #include #include using namespace std; const int MaxValue = 10000;//初始设定的权值最大值 const int MaxBit = 4;//初始设定的最大编码位数 const int MaxN = 10;//初始设定的最大结点个数 struct HaffNode//哈夫曼树的结点结构 {
2016-03-27 11:09:13 320
原创 Codeforces Round #326 (Div. 2)Problem C - Duff and Weight Lifting
#include int n,q,a[1111111],ans; main() { scanf("%d",&n); for(int i=0;in;i++) { scanf("%d",&q); a[q]++; } for(int i=0;i1111110;i++) { if(a[i]%2==1) ans++; a[i+1]+=(a[i]/2); } printf("%
2015-10-16 11:58:00 475
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人