自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

姚军

富贵非吾愿,帝乡不可期。怀良辰以孤往,或植杖而耘耔。

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

原创 英语雅思笔记

1.glittering prospect = promising prospect2.go in for = participate in = take part inI have decided to go in for IELTS next summer3. be attached to 喜欢、重视I am attached to this music4.catch on vi.变...

2019-05-28 17:30:03 544

原创 快速排序

还可以优化使用随机取值,而不是取首位的数值。使用荷兰国旗算法优化。#include<iostream>#include<cmath>using namespace std;void swap(int &a, int &b){ //交换变量a,b的值 int tmp = a; a=b; b=tmp; }void quicksort(...

2019-05-17 11:41:55 147

原创 归并排序

#include<iostream>#include<cmath>using namespace std;//a原数组 s起始 m中间 e终点 tmp临时数组 void merge(int a[], int s, int m, int e, int tmp[]){ //归并时间复杂度O(n) int k=0; int i=s,j=m+1; while(i&l...

2019-05-17 11:13:56 118

原创 找一对数

输入n(≤105)n(\le 10^5)n(≤105),找出其中2个数之和等于mmm解法一:暴力枚举 O(n2)O(n^2)O(n2)解法二:二分搜索O(nlogn)O(nlogn)O(nlogn)先对数组排序,然后对数组中的每个arr[i],二分查找m-arr[i]解法三:双指针O(nlogn)O(nlogn)O(nlogn)先对数组排序,然后使用两个指针,i=0,j=n−1i=0,j...

2019-05-17 10:41:07 272

原创 逆波兰表达式

中国MOOC课程题目主要思想是递归#include<bits/stdc++.h>using namespace std;double exp(){ char s[20]; cin>>s; switch(s[0]){ case '+': return exp()+exp(); case '-': return exp()-exp(); case '*...

2019-05-17 10:18:39 185

原创 熄灯问题

POJ1222这道题知道名字已经很久了,但是每次都是看一半都看不下去了。让我自己做肯定是做不出来的,现在更是连听别人讲解都听不懂。这次耐着性子终于听懂了,并且把代码看明白了。郭炜老师写的代码没看太懂,但是刘家瑛老师写的代码比较容易看懂,B站上有视频。我放在这里方便以后自己查看。注意:没行末尾没有多余空格。#include<iostream>#include<cst...

2019-05-17 08:30:22 592

原创 L1-007 念数字 (10 分)

使用二维字符数组然后把数字进行数位分解#include<bits/stdc++.h>int main(){ int num; char str[][10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; scanf("%d",&num); if(num<0) { printf("fu "...

2019-05-16 17:47:38 714

原创 L1-034 点赞 (20 分)

直接散列,注意出现次数相同时,输出数值大的。#include<bits/stdc++.h>int arr[1005]={0};int main(){ int n,m,num; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&m); for(int i=0;i<m;i++){ sca...

2019-05-16 17:34:39 889

原创 7-51 两个有序链表序列的合并 (20 分)

归并两个有序数组的模板#include<bits/stdc++.h>using namespace std;vector<int> A,B,C;void merge(){ int i=0,j=0,k=0; C.clear(); while(i<A.size() || j<B.size()){ if(i==A.size()&&j...

2019-05-16 12:50:53 1671

原创 7-52 两个有序链表序列的交集 (20 分)

注意:序列为空的情况。没有说明数据大小,考虑用vector存。#include<bits/stdc++.h>using namespace std;vector<int> A,B;int flag=0;void SameSet(){ int i=0,j=0; while(i<A.size()&&j<B.size()){ if(...

2019-05-16 11:23:40 1295

原创 7-53 两个有序序列的中位数 (25 分)

排序之后再寻找会超时O(nlogn)O(nlogn)O(nlogn)使用双指针是线性的O(n)O(n)O(n)#include<bits/stdc++.h>using namespace std;const int maxn=1e5+5;int A[maxn];int B[maxn];int n;int merge(){ int i=0,j=0; int mid =...

2019-05-16 11:03:22 917

原创 7-38 寻找大富翁 (25 分)

注意:N有可能比M小思路:使用选择排序或者冒泡排序,遍历M趟,一边遍历,一边输出。#include<bits/stdc++.h>using namespace std;const int maxn=1e6+5;int arr[maxn];int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=0;i&lt...

2019-05-16 10:35:40 587

原创 7-37 模拟EXCEL排序 (25 分)

排序入门题#include<bits/stdc++.h>using namespace std;const int maxn=1e5+5;struct stu{ int no; char name[10]; int score; }Node[maxn];bool cmp1(stu a, stu b){ return a.no <b.no;}bool cm...

2019-05-16 10:10:32 1094 3

原创 完数【HDOJ1406】【西安电子科技大学上机】

HDU1406题目链接注意有坑!输入的范围不保证前者一定比后者小,注意主动交换成小的在前,大的在后。//完数//欧拉筛选 #include<cstdio>#include<cmath> #include<vector>using namespace std;const int size=123456;vector<int> ar...

2019-05-14 10:10:14 526

原创 POJ1007 DNA Sorting

题目简单的模拟。逆序对正向和反向数是相同的。解法1使用三个变量来记录前面位置出现过的字母次数。#include<cstdio>#include<cstring>#include<string>#include<map>#include<cctype>#include<iostream>#include&lt...

2019-05-14 08:29:16 134

原创 POJ1002 487-3279

题目模拟#include<cstdio>#include<cstring>#include<string>#include<map>#include<cctype>#include<iostream>using namespace std;char temp[100];char str[100];int...

2019-05-14 07:36:51 119

原创 Sticks【POJ1011】【HDOJ1455】

木棍根据别人的代码改写的,大体思路没变,主要是剪枝的思想。//用scanf防止超时//剪枝 + dfs #include<cstdio>#include<cstring>#include<algorithm>using namespace std;bool cmp(int a, int b){ return a>b;}int stic...

2019-05-11 22:18:20 176

原创 L2-023 图着色问题 (25 分)

L2-023 图着色问题 (25 分)注意:顶点的编号是从1开始的 ,同时要判断给定的给出的颜色数是否等于k#include<bits/stdc++.h>#include<iostream>using namespace std;int v,e,k,x,y,n;vector<int> G[505];int arr[505];set<int&...

2019-05-03 12:20:54 456

空空如也

空空如也

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

TA关注的人

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