自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 收藏
  • 关注

转载 DFS

转自:https://www.cnblogs.com/OctoptusLian/p/7429645.htmlvoid dfs(int x,int y,int step){ int tx,ty; int next[4][2]= {{-1,0},{1,0},{0,-1},{0,1}}; if(x==endx &&y==endy) { ...

2019-03-02 19:53:24 118

转载 STL——Binary search(二分查找)

转自:http://www.cnblogs.com/wkfvawl/p/9475939.html二分算法模板:while (left <= right) { int mid = (left + right) / 2; if (array[mid] == key) { return mid; } ...

2019-03-01 18:41:56 136

原创 二分查找模板

#include<stdio.h>#include <algorithm>#include <cstring>#include <cstdio>#include <stdio.h>using namespace std;int main(){    int a[1000];    int n;    scanf("%...

2019-02-27 16:20:33 162

转载 最短路模板

#define Max 0x3f3f3f3f#define maxn 10010int n,m;int Map[maxn][maxn];int dist[maxn];int vist[maxn];Floyd:void floyd(){ int i,j,k; for (k=1; k<=n; k++) for(i=1; i<=n; i...

2018-11-24 16:12:30 176

原创 HDU2544——最短路(最短路Dijkstra)

http://acm.hdu.edu.cn/showproblem.php?pid=2544题意描述:A,B为路口编号,C为AB之间的权值,计算最短路Floyd方法#include <stdio.h>#include <cstring>#include <string.h>#include <iostream>using na...

2018-11-03 10:29:44 187

原创 HDU1143——Tri Tiling(DP)

题目: http://acm.hdu.edu.cn/showproblem.php?pid=1143思路:把大矩形用竖线切出左边一部分,然后递归求解,竖线是沿着纹路分的,右面就是f(n-2)有三种情况,即3*f(n-2)。左面是f(n-4),只有两种情况(注意左面再分是,是不可以出现一条竖线可以切分的情况,所以只有两种情况)。递推公式出现:f(n)=3*f(n-2)+2*f(n-4)+…+...

2018-10-29 20:07:15 133

原创 #defind 和 const

#define 定义的只是个常数 不带类型。define是在编译的预处理阶段起作用 const 定义的常数是变量 也带类型。const是在 编译、运行的时候起作用。eg:#define n 100;const int n=100;#define ull unsigned long longconst ull B = 1e8+7;  加一个知识点:unsigned ...

2018-10-17 19:44:46 202

转载 快速幂---(+位权、位运算)

先介绍两个知识点二进制的位权问题1、对于多位数,处在某一位上的“1”所表示的数值的大小,称为该位的位权。例如十进制第2位的位权为10,第3位的位权为100;而二进制第2位的位权为2,第3位的位权为4,对于 N进制数,整数部分第 i位的位权为N^(i-1),而小数部分第j位的位权为N^-j。数码所表示的数值等于该数码本身乘以一个与它所在数位有关的常数,这个常数称为“位权”,简称“权”。...

2018-10-17 16:18:01 1030

转载 递推算法之平面分割问题总结

一、n条直线最多分平面问题       题目大致如:n条直线,最多可以把平面分为多少个区域。       析:可能你以前就见过这题目,这充其量是一道初中的思考题。当有n-1条直线时,平面最多被分成了f(n-1)个区域。则第n条直线要是切成的区域数最多,就必须与每条直线相交且不能有同一交点。 这样就会得到n-1个交点。这些交点将第n条直线分为2条射线和n-2条线断。而每条射线和线断将以有的区...

2018-10-13 16:20:58 666

转载 Java中的构造方法

构造方法作用就是对类进行初始化。 如果你没有定议任何构造方法的形式,程式会为你取一个不带任何参数的构造函数,那么你产生类的对像时只能用不带参数的方法,如:class a {}//没有任何构造函数。构造方法就是与类同名的那个方法,它的作用是可以用来初始化,例子如下class Person //人类{public Person(String n,int a) //构造方法{ name =...

2018-10-13 16:20:38 85

原创 compaper 函数 C++中

 compare函数用来进行字符串以及其子串的比较,示例如下: #include <iostream> #include <string> #include <cctype> using std::cout; using std::endl; using std::cin; using std::string; int ma...

2018-10-13 16:20:17 251

转载 HDU2049 + 错排

错排证明:有个牵手游戏规则如下:有标号 1.的女生与标号1,2,3,4......n-1,n.的男生.我们规定标号相同的男生与女生不能牵手。同时规定错排个数为M(1),M(2),M(3)。。。M(n-1),M(n),我们假设1号女生先开始牵手,那么有n-1种选法,我们假设2号女生牵手1和不牵1男生手的两种情况,假设2一定牵手1,那么还有编号3,4......n-1,n的男女...

2018-10-13 16:20:02 91

原创 HDU1312——Red and Black (DFS)

Red and BlackTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12907    Accepted Submission(s): 7983Problem DescriptionThere is a rectangular room...

2018-05-27 20:04:43 99

原创 HDU1241——Oil Deposits (DFS)

题目:The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvCompworkswithonelargerectangularregionoflandatatime,andcreatesagridthatdivides the land into nu...

2018-05-23 20:20:42 151

原创 POJ1426——Find The Multiple (BFS)

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there...

2018-05-23 19:32:50 102

原创 HDU1195——Open the Lock (BFS)

原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1195 #include<iostream>#include<cstdio>#include<cstring>#include<queue>using namespace std;struct node{ int num[4],s...

2018-05-21 20:19:50 190

原创 笔记——queue

queue是面对队列使用的使用queue之前,要先利用构造函数一个队列对象,才可以进行元素的入队,出队,取队首和队尾等操作;#include <iostream>#include <queue>using namespace std; //这几个头文件必不可少int main(){queue<类型(如int)> q; //使用前需定义一个queue变量,且定义时...

2018-05-18 19:32:32 113

原创 HDU1012——判断素数

1.简单暴力的方法    判断[2,n-1]区间有没有约数即可    int isPrime(int n) {      int i;      for (i = 2; i < n; ++i) {          if (n % i == 0) return 0;      }      return 1;  } 2.用sqrt(n)    约数都在sqrt(n)这个数的两边对应出现,所以...

2018-05-16 19:08:30 199

原创 练习——指针

1.调用函数求两个数的和与差void sum_diff(float op1,float op2,float *psum,float *pdiff){    *psum=op1+op2;    *pdiff=op1-op2;}int main(){    float op1,op2,sum,diff;    scanf("%f%f",&op1,&op2);    sum_diff(o...

2018-04-18 20:28:30 344

原创 笔记——指针

1.     int main()    {        int a=3,*p;        p=&a;        /* 把变量a的地址赋值给指针p,即p指向a */        printf("a=%d,*p=%d\n",a,*p);    (a=3,*p=3)        *p=10;        /* 对指针p所指向的变量赋值,相当于对变量a赋值 */        p...

2018-04-17 19:35:33 166

原创 正弦余弦的计算

1.输入的为度数:如pi/2#include<stdio.h>#include<math.h>main(){double n,b,c;scanf("%lf",&n);b=sin(n);c=cos(n);printf("%.2lf %.2lf",b,c);return 0;}2.输入的是数,如90#include<stdio.h>#include<m...

2018-04-10 22:05:58 3128

空空如也

空空如也

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

TA关注的人

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