自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 牛客网第二场D购买物品求利益

题目利用贪心的思想,寻找上升子序列。。如果下一个商品价格大于当前,继续向下遍历,否则在当前卖出,下一个买入(存到pre).注意要比较pre与判断出要在此处卖出的价格大小。#include<iostream>#include<algorithm>#include<math.h>#include<cstring>#define ll l...

2018-08-28 16:47:14 240

原创 普及练习场简单模拟P1003铺地毯

这道题的思路很简单,主要在于如何储存数据。思路一直卡在二维数组的范围上,其实人家用另一种方式分别储存横纵坐标就可以了啊,嘤。题目描述为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯。一共有 nn 张地毯,编号从 11 到 nn 。现在将这些地毯按照编号从小到大的顺序平行于坐标轴先后铺设,后铺的地毯覆盖在前面已经铺好的地毯之上。地...

2018-08-25 10:37:21 276

原创 PTA A1053 深搜与先根遍历

#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn=110;struct node{ int weight; vector<int> child;}nodes[maxn];bool cmp(int a,in...

2018-08-16 11:15:50 208

原创 KMP

并没有理解为什么j=next[j];玛德#include<iostream>using namespace std;char s[50];char text[50];char pattern[50];int next[50];void getnext(char s[],int* next,int len){ int j=-1; next[0]=-1; for(...

2018-08-13 10:36:33 120

原创 大数加法

#include<iostream>#include<string>using namespace std;struct bign{ int d[1000]; int len; bign(){ memset(d,0,sizeof(d)); len=0; }};bign change(char str[]){ bign a; a.len=s...

2018-08-06 20:37:46 110

原创 PAT A1059

给出一个int范围的整数,按照从小到大的顺序来输出其分解为质因数的乘法算式#include<iostream>#include<algorithm>using namespace std;const int maxn=100000;int prime[maxn];bool p[maxn]={false};int num=0;struct factor{...

2018-08-06 19:55:12 189

原创 数素数

#include<iostream>using namespace std;const int maxn=10010;int prime[maxn],pnum=0;bool p[maxn]={false};void findprime(int n){ for(int i=2;i<maxn;i++) { if(p[i]==false) { prime...

2018-08-06 16:42:07 134

原创 快速排序

#include<iostream>using namespace std; int partition(int a[],int left,int right) { int temp=a[left]; while(left<right) { while(left<right&&a[right]>temp) { r...

2018-08-06 10:59:41 140

原创 归并排序

#include<iostream>using namespace std;const int maxn=100;void merge(int a[],int l1,int r1,int l2,int r2){ int i=l1; int j=l2; int temp[maxn]; int index=0; while(i<=r1&&j<...

2018-08-06 10:16:36 138

原创 简单贪心月饼PATB1020

算法笔记118-119 #include<iostream>#include<algorithm>using namespace std;struct node{ double cun; double shou; double bi;}nodes[1010];bool cmp(node a,node b){ return a.bi>b....

2018-08-01 19:37:37 205

原创 递归求全排列。1-n

#include<iostream>using namespace std;const int maxn=11;int n,p[maxn],hashTable[maxn]={false};void generateP(int index){ if(index==n+1) { for(int i=1;i<=n;i++) { printf("%d",p[i...

2018-08-01 16:04:53 331

原创 字符串hash初步

 给出N个字符串(三个小写字母),再给出M个查询字符串,问每个查询字符串在N个字符串中出现的次数。#include<iostream>using namespace std;const int maxn=100;char s[maxn][5],temp[5];int hashTable[26*26*26+10];int hashFunc(char s[],int l...

2018-08-01 15:20:48 191

空空如也

空空如也

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

TA关注的人

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