自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

LeetCode

What hurts more, the pain of hard work or the pain of regret?

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

原创 甲级pat-a 1040

        #include<iostream>#include<cstdio>using namespace std;int dp[1001][1001];int main(){ string s; getline(cin,s); int len=s.length(),ans=1; for(int i=0;i<len;i+...

2018-05-21 19:32:57 133

原创 甲级pat-1038

#include<iostream>#include<string>#include<algorithm>using namespace std;const int maxn=10001;string s[maxn];bool cmp(string a,string b){ return a+b<b+a; //使a<b}int...

2018-05-21 19:31:31 159

原创 甲级pat-1032

#include<cstdio>#include<vector>using namespace std;const int maxn=100001;int hashTable[maxn]={0};struct Node{ int address; char data; int next;}node[maxn];int main(){ ...

2018-05-21 19:29:48 145

原创 甲级pat-1030

#include<cstdio>#include<algorithm>using namespace std;const int maxn=1001;const int INF=10000000;int n,m,st,ed;int d[maxn],G[maxn][maxn],cost[maxn][maxn],w[maxn],pre[maxn];bool vis...

2018-05-21 19:28:50 185

原创 甲级pat-1027

#include<cstdio>int main(){ char s[14]={"0123456789ABC"}; printf("#"); for(int i=0;i<3;i++){ int a; scanf("%d",&a); printf("%c%c",s[a/13],s[a%13]);

2018-05-19 14:41:57 155

原创 甲级pat-1025

能用vector尽量不用数组#include<cstdio>#include<algorithm>#include<vector>using namespace std;struct student{ long long int name; int mark; int type; int level1; int l...

2018-05-19 14:38:07 130

原创 甲级pat-1023

#include<iostream>#include<algorithm>using namespace std;int main(){ string s; cin>>s; int len=s.length(),arr_1[20],arr_2[20],arr_3[20],temp=0; for(int i=0;i<...

2018-05-19 10:49:48 160

原创 甲级pat-1019

#include<cstdio>int main(){ int a,b,arr[1001]={0},len=0; scanf("%d %d",&a,&b); do{ arr[len++]=a%b; a=a/b; }while(a!=0); bool flag=true; for(int i...

2018-05-19 10:25:06 139

原创 甲级pat-1002

#include<cstdio>#include<iostream>using namespace std;const int maxn=1001;int main(){ int n,m; scanf("%d",&n); int p; double c,arr[maxn]={0.0}; for(int i=0;i&lt...

2018-05-19 09:23:40 121

原创 甲级pat-1011

#include<cstdio>#include<algorithm>using namespace std;char s[3]={'W','T','L'};int main(){ double arr[3][3]={0},sum,fin[3],MAX=0.0; for(int i=0;i<3;i++) scanf("%lf %...

2018-05-19 09:20:06 125

原创 甲级pat-1009

#include<cstdio>const int maxn=5000;double arr[maxn]={0.0},arr1[maxn]={0.0},arr2[maxn]={0.0};int main(){ int n,m; scanf("%d",&n); int a; double b; for(int i=0;i<n;i...

2018-05-19 09:18:06 123

原创 甲级pat-1006

类型:sort函数排序#include<cstdio>#include<algorithm>#include<iostream>using namespace std;const int maxn=10010;struct Node{ string id; int in,out;}node[maxn];bool cmp1(Node ...

2018-05-19 09:12:24 142

原创 甲级pat-1005

#include<iostream>using namespace std;char arr[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};const int ma

2018-05-19 09:10:09 279

原创 甲级pat 1003

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=1001;const int INF=10000000;int n,m,s,t;//d[]表示的是起始点到每个定点的最短路径,G[][]表示的是每两个定点之间的路径长度,cos...

2018-05-19 09:08:28 208

原创 甲级pat-1087

#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>#include<map>using namespace std;const int maxn=1000;const int INF=100...

2018-05-10 21:15:40 332

原创 甲级pat-1107

#include<cstdio>#include<algorithm>using namespace std;const int maxn=1010;int father[maxn];int isRoot[maxn]={0};int course[maxn]={0};int findfather(int x){ int a=x; while(x...

2018-05-10 21:03:09 238

原创 通过数组对二叉树进行遍历

在刷pat的时候经常遇到用数组进行存取二叉树,但是不会遍历二叉树(看来是我太菜了),原来数组存取的二叉树的遍历和普通的遍历基本相同,下面给出用数组存取二叉树的前序,中序和后序遍历。#include<cstdio>#include<vector>using namespace std;vector<int> v(1000,-1);int n;void preord...

2018-05-10 20:56:12 3906 1

原创 堆排序

#include<cstdio>#include<algorithm>using namespace std;const int maxn=100010;int heap[maxn],n;void downAdjust(int low,int high){    int i=low,j=i*2;  // i为欲调整的节点,j为其左子树    while(j<=high...

2018-05-10 20:47:30 93

原创 甲级pat-1115

#include<cstdio>#include<vector>#include<queue>using namespace std;struct Node{    int data;    Node *lchild,*rchild;};// 进行二叉树的建立void insertData(Node* &root,int data){    if(roo...

2018-05-10 20:45:59 198

原创 avl树的基本操作

#include<cstdio>#include<algorithm>#include<queue>using namespace std;struct node{    int v,height; //v为节点的权值,height为当前子树的高度    node *lchild,*rchild; //左右子树结点地址} *root;// 新建根节点node* ...

2018-05-10 20:42:48 362

原创 贪心算法学习

最近刷pat,见了许多关于贪心算法的题目,刚好又读到算法笔记,就把关于贪心算法的题列出来,总结一下。pat-b-1023给定数字0-9各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意0不能做首位)。例如:给定两个0,两个1,三个5,一个8,我们得到的最小的数就是10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:每个输入包含1个测试...

2018-03-03 23:08:43 483

原创 字符串hash表示简介

字符串hash是指讲一个字符串s映射为一个整数,使得该整数可以尽可能唯一的代表字符串s。可以进行字符串的判断。代码如下:#include<iostream>  #include<cstring>  int hashtable[26*26*26+10];  using namespace std;  int translate(string s){      int sum=...

2018-03-03 21:42:33 204

原创 散列归纳

散列可以用空间来换取时间,比如   :给出N个镇正整数,再给出M个正整数,问着M个数中的每个数分别数是否在N个数中出现过。如果之间进行查询遍历,时间复杂度为O(MN),当MN很大时,显然是无法承受的。那么就用空间复杂度对时间复杂度进行转换,即设定一个bool类数组hashtable【100010】,其中hashtable【x】=true表示正整数x在N个正整数中出现过,而hashtable【x】=...

2018-03-03 21:30:54 109

原创 数据结构复习整理——队列的基本操作

#include#include#define ERROR 0#define OK 1typedef struct QNode{    int data;    struct QNode *next;}QNode,*QueuePtr;typedef struct {    QueuePtr front;    QueuePtr rear;}LinkQue

2017-12-11 19:23:48 247

原创 数据结构复习整理——栈的基本操作

#include#include#define STACK_INIT_SIZE 100#define STACKINCREMENT 10#define ERROR 0#define OK 1typedef struct {    int *base;    int *top;    int stacksize;}Sqstack;//建立栈in

2017-12-11 19:22:50 184

原创 数据结构复习整理——二叉树的基本操作

#include#include#includeusing namespace std;typedef char TElemType;typedef struct BiTNode{    TElemType data;    struct BiTNode *lchild,*rchild;} BiTNode,*BiTree;//二叉树的建立void

2017-11-30 18:18:52 173

原创 数据结构复习整理——线性表链式存储的基本操作

#include#include#include#includeusing namespace std;typedef int ElemType;struct LNode{    ElemType data;    struct LNode *next;};//链表的建立struct LNode* Build(struct LNode *he

2017-11-30 18:17:27 441

空空如也

空空如也

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

TA关注的人

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