自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

来自大白的渴望

趁还年轻,趁还有梦

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

转载 2018.6.15(01dp-hdu2059龟兔赛跑)

解题思路路: 动态规划题⽬目。dp[i]数组⽤用来保存从起点到当前第i个充电站所⽤用的最短时间. 它等于dp[j] (j#include<iostream>#include<cstdio>using namespace std;#define INF (~(0x1<<31))int main(){ int

2018-06-15 09:06:20 252

原创 2018.6.11(洛谷 P1031 均分纸牌)

https://www.luogu.org/problemnew/show/P1031题解(参考大神题解): 因为每堆牌只能移到相邻的堆,不妨一堆堆处理,且只考虑后一堆(因为前一堆已经处理好了,再移动会造成浪费)。那么如果出现了负数呢?如1,1,7的情况,从左到右处理过程如下:1,1,73,-1,73,3,3但可以证明,这样依然不会丢失最优解(只是改变了顺序)。#in...

2018-06-12 13:31:45 213

原创 2018.6.9(hdu1232-畅通工程)

解题方法:并查集 并查集详解 https://blog.csdn.net/the_best_man/article/details/62416938#include<iostream>#include<cstdio>#include<map>using namespace std;map<int ,int >father;ma...

2018-06-09 11:35:05 263

原创 2018.6.8(用sscanf,strtok读入数据)

sscanf()和正则表达式 https://blog.csdn.net/kenby/article/details/4051018strtok http://www.cnblogs.com/aduck/articles/2245364.htmlC语言itoa()函数和atoi()函数详解(整数转字符C实现) https://www.cnblogs.com/bluestorm/p/3...

2018-06-08 21:16:35 207

转载 2018.6.8(hdu2062 Subset sequence)

参考大神思路 https://blog.csdn.net/lianqi15571/article/details/8877014链表版AC代码#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;const int maxn=100;struct S...

2018-06-08 16:40:04 326

原创 2018.6.8(prefex tree)

#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;struct Trie{ int pass; int end; Trie *next[26];};void Initial(Trie *node)//传入参数前,确保实参已经分配好...

2018-06-08 09:44:15 187

原创 2018.6.7(多态性----几何形体处理程序----mooc)

#include<iostream>#include<cstdio>#include<cmath>#include<cstdlib>using namespace std;class Shape{public: virtual do

2018-06-07 21:34:10 755

原创 2018.6.6(最小生成树)

最小生成树:构造的连通网的最小代价生成树普里姆(prim)算法算法详解: 如图所示无向图 prim算法是任意找一点,取与这一点相关的所有边中权值最小的边,这条边又开辟了一块新结点,依次操作,直到n个结点连通,且只有(n-1)条边; 假设n=9,当前取的边数为total=0,取的第一个点为v0点,定义一个优先队列Q(排序方式是由小到大),与v0相连的边有两条,分别加...

2018-06-06 15:49:20 180

原创 2018.6.4(public继承的赋值兼容规则)

https://www.icourse163.org/learn/PKU-1002029030?tid=1002785058#/learn/content?type=detail&id=1003870398&cid=1004682699&replay=true#include<iostream>#include<cstdio>using na

2018-06-04 21:43:00 168

原创 2018.6.4(map进阶----codeforces C. Equal Sums)

http://codeforces.com/contest/988/problem/C以下代码拷贝大神代码#include<cstdio>#include<cstring>#include<algorithm>#include<io

2018-06-04 19:52:21 224

原创 2018.6.3(运算符重载)

视频教程(北大mooc): https://www.icourse163.org/learn/PKU-1002029030?tid=1002785058#/learn/content?type=detail&id=1003870385&cid=1004682687&replay=true 菜鸟教程: http://www.runoob.com/cplusplus/cp...

2018-06-03 20:19:42 246

原创 2018.6.3(图的建立--Adjacency List)

大话数据结构 #include<iostream>#include<cstdio>#include<cstdlib>using namespace std;const int maxn=110;struct Edge_Node//边表结点{ int data;//邻接点域,存储该顶点对应的下标 int weight;//存...

2018-06-03 14:32:04 3043 2

原创 2018.6.1(hdu 2061 Treasure the new start, freshmen!)

此题并不难,主要是有一些坑 1:题干没说credts,score为整数,可能为小数 2:输出格式,两个数据间有空行,最后一个数据输出后无空行#include<iostream>#include<cstdio>using namespace std;int main(){ int N; cin>>N; while(N--)...

2018-06-01 09:23:26 136

转载 2018.5.31(hdu 2060 Snooker)

http://acm.hdu.edu.cn/showproblem.php?pid=2060转载: https://blog.csdn.net/libin56842/article/details/17635207 题意详解: 下面是别的大牛解释的题意题意为,给你场上剩下的球数m , 和 a ,b 两名队员目前得分,现在假设a将所有的球m都打入洞中,然后让你输出是否最终a的得分会...

2018-05-31 14:37:56 156

原创 2018.5.30(类的静态成员)

菜鸟教程: https://m.runoob.com/cplusplus/cpp-static-members.html我们可以使用 static 关键字来把类成员定义为静态的。当我们声明类的成员为静态时,这意味着无论创建多少个类的对象,静态成员都只有一个副本。静态成员在类的所有对象中是共享的。如果不存在其他的初始化语句,在创建第一个对象时,所有的静态数据都会被初始化为零。我们不能把静态...

2018-05-30 21:51:48 142

原创 2018.5.30(this指针)

this指针:#include<iostream>#include<cstdio>using namespace std;class Text{private: int length,breadth,height;public: Text(int l,int b,int h); int Volume(); int com...

2018-05-30 21:49:48 132

原创 2018.5.30(二分查找应用)

problem description 1: 给定一整形有序数组,给定一整数x,在数组中找出x第一次出现是的下标(从1开始) 输入: 6 2(n,x) 0 2 2 2 3 9(n个有序数组) 输出: 2(2第一次出现的位置)#include<iostream>#include<cstdio>using na...

2018-05-30 20:15:59 139

转载 2018.5.29(stl-map)

转载: http://www.cnblogs.com/fnlingnzb-learner/p/5833051.htmlC++中的STL中map用法详解Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。这里说下map...

2018-05-29 15:49:45 160

转载 2018.5.28(hdu 2058-The sum problem)

http://acm.hdu.edu.cn/showproblem.php?pid=2058本来想前缀和搞搞的,一看1 <= N, M <= 1000000000,看来是公式题,给出一个M,不可能从1枚举到1000000000,所以要找一个枚举范围,等差数列求和公式:sum=n*a1+n*(n-1)/2,n要最大,就要a1=1,所以sum=n*(n+1)/2,变一下n#incl...

2018-05-28 14:39:43 147

转载 2018.5.27(sscanf函数和正则表达式)

转载 http://kmplayer.iteye.com/blog/556293此文所有的实验都是基于下面的程序: char str[10]; for (int i = 0; i < 10; i++) str[i] = ‘!’; 执行完后str的值为 str = “!!!!!!!!!!” 我们把str的每个字符都初始化为惊叹号,当str的值发生变化时,使用print...

2018-05-27 21:30:30 285

原创 2018.5.27(hdu1276 士兵队列训练问题)

先上AC代码,解析稍后献上~~~~#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;struct Soldier{ int initial_number; So

2018-05-27 09:55:32 277

原创 2018.5.26(求完全二叉树的结点个数)

完全二叉树: 一棵树去除掉最大阶层后为一满二叉树,且阶层最大那层的结点均向左靠齐,则该二叉树为完全二叉树; 求完全二叉树的结点个数要求时间复杂度低于O(n)思路剖析: 调用递归解决问题,先求出当前树的深度,在判断当前根结点的左右子树哪个为满二叉树,如果左二叉树为满二叉树,调用递归函数Is_FBT(head->right,total_node+(1<...

2018-05-26 17:36:31 1484

转载 2018.5.26(欧拉函数)

欧拉函数算法分析在数论中,对正整数N,欧拉函数是小于或等于N的数中与N互质的数的数目。N的欧拉函数值记为 phi(n)例如 phi(8)=4 (4个与8互质的数分别为 1 3 5 7)通式:,其中p1, p2……pn为x的所有质因数,x是不为0的整数。φ(1)=1(唯一和1互质的数(小于等于1)就是1本身)。 (注意:每种质因数只一个。比如12=2*2*3那么φ(12...

2018-05-26 15:30:25 746

原创 2018.5.26(容斥原理、鸽巢原理)

*鸽巢原理***00 死神来了 解析: 前n个数,两两之间互不整除的数最多有ans=n/2+n&1; 例如: n->ans(两两之间互不整除的数最多的情况) 3->2(3,2)———-n/2+1; 4->2(4,3)———-n/2; 5-&a

2018-05-26 15:25:54 225

原创 2018.5.26(平衡二叉树?)

平衡二叉树概念:它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树。面向对象代码#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;class Tree{public: int data; Tre...

2018-05-26 09:28:56 146

原创 2018.5.24(Wannafly挑战赛15 --C出队---约瑟夫环)

https://www.nowcoder.com/acm/contest/112#questionC出队https://www.nowcoder.com/acm/contest/112/C 这是关于“约瑟夫环”的系列问题#include<iostream>#include<cstdio>using namespace std;i

2018-05-24 13:52:51 363

原创 2018.5.23(c++面向对象--复制构造函数)

复制构造函数#include<iostream>#include<cstdio>using namespace std;class Test{public: double real,image;public: Test ()//无参构造函数 { }; Test (double n)//含有一个参数的构造函数 ...

2018-05-23 21:55:44 140

原创 2018.5.23(二叉树-中序遍历中查找某一结点的后继结点)

#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;struct Tree{ int data; Tree *parent;//存储某一结点的父结点 Tree *left,*right;};Tree *Insert(Tree *ro...

2018-05-23 19:55:41 833

翻译 2018.5.22(树的图形化显示-理解)

//需在加头文件#include<windows.h>//GraphShow()函数中x,y为输出结点的坐标,k=0,1,2分别代表结点为根,左子,右子,space控制输出的树宽度//改程序仅能在windows平台上运行#include<iostream>#include<cstdio>#include<cstdlib>#include&...

2018-05-22 20:09:53 1086

原创 2018.5.22(二叉树的遍历-非递归(手动压栈))

遍历解释–递归版https://blog.csdn.net/Violet_ljp/article/details/80378033手动压栈#include<iostream>#include<cstdio>#include<cstdlib>#include<stack>#include<cst

2018-05-22 20:02:09 186

原创 2018.5.21(用class 计算矩形的面积、周长)

#include<iostream>#include<cstdio>using namespace std;class Rectangle{private: int w,h;public: int Area() { return w*h; } int C() { return 2*...

2018-05-21 22:01:41 254

原创 2018.5.21(&,const,函数重载,缺省函数)

引用类型名 & 引用名=某变量名int n=1;int &r=n;r=4;cout<<r;//输出4;cout<<n;//输出4;n=5;cout<<r;//输出5;定义常量–const 动态内存分配#include<iostream>#include<cstdio>usi...

2018-05-21 21:58:31 159

原创 2018.5.21(荷兰国旗问题--链表版)

用链表解决荷兰国旗问题可以保证排序的稳定性#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;struct List{ int data; List *next;};void print(List *head){ for(...

2018-05-21 14:52:12 491

原创 2018.5.20(判断回文数)

判断回文数#include<iostream>#include<cstdio>#include<cstdlib>#include<stack>using namespace std;struct List{ int data; List *next;};List *Insert(List *head,int...

2018-05-20 12:21:46 226

原创 2018.5.19(二叉树的遍历-递归(系统压栈))

二叉树前根序、中根序、后根序遍历分析借鉴大神博客 https://blog.csdn.net/prince_jun/article/details/7699024前根序遍历#include<iostream>#include<cstdio>#include<cstring>using namespace s

2018-05-19 21:20:04 390

原创 2018.9.19(二叉树)

链表表示题目描述:用链表建立二叉树。 有一棵深度为N(N<=20)的树,请用链表建立二叉树。 【输入格式】 第一行为一正整数N,表示有多少个元素,第二行为N个元素 【输出格式】 按数组顺序输出即可。 【输入样例】 9 6 3 8 5 2 9 4 7 10 【输出样例】 6 3 2 5 4 8 7 9 10#include<iostream>#incl...

2018-05-19 20:27:26 188

原创 2018.5.19(链表)c语言版

#include<iostream>#include<cstdio>#include<cstdlib>using namespace std;struct List{ int data; List *next;};List *Create_01()//按输入顺序建立链表;{ List *head=NULL,*tail=...

2018-05-19 17:08:01 143

原创 2018.5.19(打印矩阵)------宏观调整

打印矩阵转圈打印矩阵描述: 代码1#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int n,m; while(cin&

2018-05-19 14:57:43 140

原创 2018.5.19(读入字符,踩坑)

坑坑坑如果程序中需要输入字符,如果在读入字符前读入了其他数据,一定要记得用getchar()吸收回车或空格char ch1[10]; char ch;scanf(“%s”,ch1); getchar(); scanf(“%c”,ch);...

2018-05-19 09:36:50 130

原创 2018.5.17(归并排序)

归并排序#include<iostream>#include<cstdio>using namespace std;void Merge(int a[],int l,int mid,int r);void MergeSort(int a[],int l,int r){ if(l==r) return ; int mid=...

2018-05-17 21:46:50 126

三次握手、四次挥手.zip

三次握手、四次挥手.zip

2022-12-27

空空如也

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

TA关注的人

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