自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(137)
  • 资源 (4)
  • 收藏
  • 关注

原创 牛客练习赛79题解

牛客练习赛79题解 A 炼金术师考试的时候想的是从后面到前面遍历,有不同的颜色,就加一,但是没有通过,一直段错误利用栈来维护 1、新加入的颜色的长度和栈顶元素比较,如果当前的这个栈顶元素的长度小于新加入的颜色的长度,就表示新加入的颜色可以覆盖栈顶元素的颜色,所以就把栈顶弹出。 2、遇到覆盖不了的元素就可以把这个颜色加入栈了。#include<bits/stdc++.h>using namespace std;stack<int> s;int mai

2021-03-27 11:41:35 153

原创 PTA 1055 The World‘s Richest

题目描述分析:结构体排序,在sort排序时可以使用lambda表达式书写,更方便参考博客:C++之Lambda表达式官方文档#include<iostream>#include<algorithm>#include<string>using namespace std;struct person{ string name; int age; int worth;}p[100005];int main(){ int

2021-03-13 10:47:50 112

原创 PTA 1061 Dating

题目描述分析:找出字符串中相同的字符,利用map存储字符的对应关系#include<unordered_map>#include<cstdio>#include<iostream>#include<string>#include<algorithm>using namespace std;typedef long long ll;int main(){ ios::sync_with_stdio(false);

2021-03-13 10:16:27 128

原创 PTA 1071 Speech Patterns

题目描述分析:使用map记录每个字符串出现的次数即可C++ isalpha、isalnum、islower、isupper用法#include<map>#include<iostream>#include<string>using namespace std;int main(){ map<string,int> mp; string str,temp=""; getline(cin,str); for(int

2021-03-13 09:41:22 86

原创 PTA 1077 Kuchiguse

题目描述分析:找出最长公共后缀,可以先把字符串翻转,转换成找前缀方便处理。完后循环遍历即可#include<algorithm>#include<iostream>#include<string>#include<cstdio>using namespace std;string str[105];int main(){ int n; cin>>n; getchar(); int len=256;

2021-03-13 09:24:30 54

原创 PTA 1040 Longest Symmetric String

题目描述分析:找出子串中最长的回文串,选定一个中心,从中心向两边遍历#include<bits/stdc++.h>using namespace std;int main(){ string s; getline(cin,s); int maxLen=0; for(int i=0;i<s.size();++i){ int j; for(j=1;i-j>=0&&i+j<s.size()&am

2021-03-13 09:07:36 64

原创 PTA 1017 Queueing at Bank

题目描述分析:复杂模拟,模拟银行等待,使用优先队列进行模拟#include<vector>#include<queue>#include<algorithm>#include<cstdio>#include<cLIMITS>using namespace std;struct customer{ int arrive; int process;}cs;bool cmp(const customer&

2021-03-13 08:42:45 60

原创 PTA 1129 Recommendation System

题目描述分析:用户购买一件商品,就向他推荐K个商品。定义一个结构体goods,包含商品的编号、购买次数,并按排序要求重载小于运算符。定义一个set,对购买过的商品进行自动排序。#include<set>#include<iostream>using namespace std;struct goods{ int index; int num=0; goods(int i,int n):index(i),num(n){} bool op

2021-03-12 16:43:12 88

原创 PTA 1124 Raffle for Weibo Followers

题目描述分析:简单模拟即可在使用vector的时候如果不指定大小会报段错误,应该是由于数据过多,导致分配给vector的大小不够所致,坑坑坑#include<unordered_set> #include<vector>#include<iostream>#include<string>using namespace std;int main(){ int m,n,s; cin>>m>>n>

2021-03-12 16:23:24 74

原创 PTA 1128 N Queens Puzzle

题目描述分析:简单模拟,给出一个皇后所在行的序列,判断是否符合要求#include<cstdio>#include<cmath>using namespace std;int n;int h[1005];bool judge(){ for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ if(h[i]==h[j]||abs(j-i)==abs(h[j]-h[i]))

2021-03-12 15:46:32 65

原创 PTA 1125 Chain the Ropes

题目描述分析:贪心,要使绳子最长,需要先连接最短的绳子,只需把绳子排序即可。C++的STL中accumulate的用法#include<vector>#include<algorithm>#include<iostream>#include<cmath>#include<numeric>using namespace std;typedef long long ll;int main(){ ios::sync_wi

2021-03-12 15:19:52 67

原创 PTA 1121 Damn Single

题目描述分析:利用map存储配偶,利用set存储单身人数,假设此人没有配偶则直接插入set,假设此人有配偶,判断set中是否已有该人的配偶,没有的话插入此人,有的话删除此人的配偶。#include<unordered_map>#include<set>#include<algorithm>#include<cstdio>using namespace std;typedef long long ll;unordered_map<ll,

2021-03-12 14:55:28 66

原创 PTA 1110 Complete Binary Tree

题目描述分析:判断所给树是否是完全二叉树,层序遍历二叉树,判断即可#include<cstdio>#include<queue>#include<iostream>#include<string>#include<algorithm>using namespace std;struct Node{ int left=-1,right=-1;}tree[25];int n;bool child [25]={fals

2021-03-12 10:00:56 66

原创 PTA 1108 Finding Average

题目描述分析:主要是判断输入是否合理,利用sscanf和sprintf即可C语言sprintf与sscanf函数[总结]#include<cstdio>int main(){ int n; scanf("%d",&n); double sum=0.0; int num=0; char s1[105],s2[105]; while (n--) { scanf("%s",s1); double

2021-03-12 09:24:44 66

原创 PTA 1116 Come on! Let‘s C

题目描述分析:利用散列记录每位考生的排名#include<cstdio>#include<cmath>#include<algorithm>using namespace std;int n;int hashTable[10005];bool prime[10005];void findPrime(){ fill(prime+2,prime+10005,true); for(int i=2;i<10005;i++){

2021-03-12 08:29:39 86

原创 PTA 1134 Vertex Cover

题目描述分析:利用一个散列记录各个边的顶点是否在所给点的集合中#include<cstdio>#include<cstring>struct edge{ int u,v;}e[10005];int vertex[10005];int main(){ int m,n; scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d%d",&e[i]

2021-03-11 14:45:00 60

原创 PTA 1144 The Missing Number

题目描述分析:利用set来查找即可#include <cstdio>#include<unordered_set>using namespace std;int main(){ int N,a; scanf("%d",&N); unordered_set<int>s; while(N--){ scanf("%d",&a); s.insert(a); } for(in

2021-03-11 14:25:36 71

原创 PTA 1140 Look-and-say Sequence

题目描述分析:字符串模拟 string c++详解 find_first_not_of() find_first_of() C++中的String的常用函数用法总结#include<string>#include<iostream>using namespace std;typedef long long ll;int main() { string s; ll n; cin >> s >> n; while

2021-03-11 11:30:16 53

原创 PTA 1113 Integer Set Partition

题目描述分析:把一组数分成两部分,使得差最大,两部分的数量差最小,只需把这组数排序,完后后半部分减去前半部分即可。C++自动求和函数accumulate#include<cstdio>#include<algorithm>#include<numeric>using namespace std;int main(){ int N; scanf("%d",&N); int A[N]; for(int i=0;i<

2021-03-11 11:15:04 65

原创 PAT 1149 Dangerous Goods Packaging

题目描述分析:利用map存储不相容的物品,利用set存储查询的物品序列,完后遍历set#include<unordered_map>#include<unordered_set>#include<iostream>using namespace std;typedef long long ll;unordered_map<ll,unordered_set<ll>> um;unordered_set<ll> us;

2021-03-11 11:08:27 48

原创 PTA 1148 Werewolf - Simple Version

题目描述分析:暴力枚举狼人#include<cstdio>#include<cmath>using namespace std;int lang[105];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&lang[i]); } for(int i=1;i<=n;i++){ for

2021-03-11 10:48:07 77

原创 PTA 1106 Lowest Price in Supply Chain

题目描述分析:树的遍历,找出最小的叶子结点DFS#include<cstdio>#include<vector>using namespace std;const int maxn=100005;vector<int> G[maxn];double s[maxn];double minprice=0x3fffffff*1.0;int minnum=0;double R,P;int N;void DFS(int v){ if(G[v].

2021-03-11 09:43:19 67

原创 PTA 1120 Friend Numbers

题目描述分析:set的简单应用#include<set>#include<cstdio>using namespace std;int main(){ set<int> s; int n,x,ans; scanf("%d",&n); while(n--){ ans=0; scanf("%d",&x); do{ ans+=x%10;

2021-03-11 09:24:34 40

原创 PAT 1152 Google Recruitment

题目描述分析:截取字符串,判断是否是素数 C++字符串转换(stoi;stol;stoul;stoll;stoull;stof;stod;stold)#include<string>#include<iostream>#include<cmath>using namespace std;typedef long long ll;bool isPrime(ll n){ if(n<2){ return false; }

2021-03-11 09:14:24 71

原创 PTA 1146 Topological Order

题目描述分析:拓扑排序,判断给出的序列是否是拓扑排序序列,只需要判断当前结点的度是否为0即可#include<cstdio>#include<vector>using namespace std;const int MAXV=1005;vector<int> G[MAXV];int degree[MAXV];int temp[MAXV];int a[MAXV];int main(){ int n,m; int u,v;

2021-03-11 08:43:14 70

原创 PTA 1090 Highest Price in Supply Chain

题目描述分析:树的遍历,找出价值最大的结点。DFS#include<cstdio>#include<vector>using namespace std;const int maxn=100005;vector<int> G[maxn];double s[maxn],maxprice=0;double R,P;int maxnum=0;void DFS(int v){ if(s[v]>maxprice){ maxpri

2021-03-10 20:58:49 57

原创 PTA 1030 Travel Plan

题目描述最短路径问题,并且输出最短路径,经典例题,多多品味,对于这种题应该可以很快敲出#include<cstdio>#include<algorithm>#include<vector>using namespace std;struct Node{ int v,dis,cost; Node(int a,int b,int c){ v=a; dis=b; cost=c; }};co

2021-03-10 18:44:43 88

原创 PTA 1049 Counting Ones

题目描述分析:找出1~N之间的所有数字中1出现的次数,暴力会超时(但是考试时也会得到部分分)#include<iostream>#include<algorithm>using namespace std;int ans;int main(){ int n; scanf("%d", &n); int a = 1, left, right; while (n / a) { int now = n / a

2021-03-10 15:26:11 73

原创 PTA 1031 Hello World for U

题目描述分析:n1+n2+n3=N+2n1=n3<=n2且n1,n3尽可能最大3<=n2<=N#include<cstdio>#include<iostream>#include<string>#include<algorithm>using namespace std;int main(){ string str=""; getline(cin,str);//读取字符串 int n1=(str.

2021-03-10 15:04:35 61

原创 PTA 1015 Reversible Primes

题目描述分析:将一个数在k进制下翻转,判断这个数和翻转后的数是否都是素数,埃氏筛找出素数表,完后进制转换#include<cstdio>#include<algorithm>using namespace std;const int INF=1e5;bool prime[INF];void findPrime(){ fill(prime+2,prime+INF,true); for(int i=2;i<INF;i++){ if

2021-03-10 14:52:42 62

原创 PTA 1024 Palindromic Number

题目描述分析:把一个整数和他的翻转数加起来,判断是否是回文数,大整数加法#include<cstdio>#include<string>#include<iostream>#include<algorithm>using namespace std;string s1,s2;void add(){ int carry=0; for(int i=0;i<s1.size();i++){ int k=s1[i]

2021-03-10 14:35:42 57

原创 PTA 1022 Digital Library

题目描述分析:此题运用map可以很方便的解决,使用unordered_map或者map都可以,但是unordered_map由于是无序的查找速度更快,键值对中每个值采用set集合来存储#include<map>#include<cstdio>#include<set>#include<algorithm>#include<iostream>#include<string>using namespace std;

2021-03-10 12:00:43 55

原创 PAT 1023 Have Fun with Numbers

题目描述分析:给出一个数,求出这个数的二倍,判断二倍是否是原数的数位的一个新排列大整数乘法,利用string存储大整数,从个位数开始乘,利用散列表记录原数出现的数的次数,判断二倍的数是否是原数的数位的一个新排列。#include<iostream>#include<string>#include<cstdio>#include<algorithm>using namespace std;string mul(string num){

2021-03-10 10:56:38 48

原创 PAT 1010 Radix

题目描述分析:给出两个数,一个数的进制已知,寻找和这个数相等的另一个数的k进制,若是有多个k输出最小的一个。把两个数都转换成十进制进行比较,寻找进制的时候采用二分查找的方法,二分查找的下限是已知进制数的最大的位数加1,上限是已知进制数的十进制数。#include<cstdio>#include<map>#include<algorithm>using namespace std;map<char,int> mp;typedef long

2021-03-10 10:29:14 42

原创 PTA 1107 Social Clusters

题目描述分析:并查集的应用,并查集还是应该多多练习#include<cstdio>#include<algorithm>using namespace std;int father[1005];int isRoot[1005]={0};int course[1005]={0};int findFather(int x){ int a=x; while(x!=father[x]){ x=father[x]; } while(a!=father[a]){

2021-02-16 15:14:48 54

原创 PTA 1066 Root of AVL Tree

题目描述分析:平衡二叉树例题,还是有一定难度,比较复杂的,不过直接输出中位数也可以得到一定分数。#include<cstdio>#include<algorithm>using namespace std;struct node{ int v,height; node *lchild,*rchild;}*root;node* newNode(int v){ node* Node=new node; Node->v=v; Node->heigh

2021-02-16 10:31:33 75

原创 PAT 1043 Is It a Binary Search Tree

题目描述分析:给出N个正整数插入一棵二叉排序树,问这串序列是否是该二叉排序树的先序序列或者是该二叉排序树的镜像树的先序序列,输出后序序列。构建二叉排序树,镜像树的先序遍历只需要交换左右子树的访问顺序即可。#include<cstdio>#include<vector>using namespace std;struct node{ int data; node* left,*right;};void insert(node* &root,int da

2021-02-16 09:42:52 60

原创 PTA 1099 Build A Binary Search Tree

题目描述分析:给出二叉树的每个结点的左右孩子结点的编号,给出一个序列,插入到二叉树中使得成为一个二叉搜索树。对于一个二叉搜索树,中序遍历序列是递增的,只需要把给定序列排序,然后对二叉搜索树进行中序遍历,将排序后序列的整数按中序遍历的顺序填入二叉树,就可以形成二叉搜索树。#include<cstdio>#include<queue>#include<algorithm>using namespace std;struct node{ int data;

2021-02-16 09:05:11 82

原创 PTA 1064 Complete Binary Search Tree

题目描述分析:构建一个完全二叉搜索树,CBT进行中序遍历,其中序遍历序列是递增的,先将数字排序,完后进行中序遍历,遍历过程中填入数组即可得到CBT,而CBT是按照层序来存放结点的,所以只需要将数组元素顺序输出即可得到层序遍历序列。#include<cstdio>#include<algorithm>using namespace std;int num[1005],CBT[1005],index=0;int n;void inOrder(int root){ if

2021-02-16 08:34:22 82

原创 PTA 1094 The Largest Generation

题目描述分析:找出一棵树哪一层的结点数最多,DFS或者BFS搜索每层的结点数即可,存到一个数组中,最后选出最大值,树的存储采用二维数组存储。#include<cstdio>#include<vector>using namespace std;vector<int> node[105];int hashTable[105]={0};void DFS(int index,int level){ hashTable[level]++; for(int

2021-02-15 20:47:10 46

Javaweb课程设计

Javaweb课程设计,刺激精英游戏管理系统,前端采用bootstrap进行开发,后端采用Javaweb技术servlet,jsp技术,采用MVC的设计模式,数据库采用mysql。 利用本系统注册登录游戏账号,可以很好的管理自己的游戏信息以及在商城购买游戏装备,仓库查看游戏装备,参与游戏活动

2021-01-13

燕山大学操作系统讨论课报告以及答辩PPT

燕山大学操作系统讨论课报告以及答辩PPT,本次讨论课内容是操作系统中存在的创新。本小组(01小组)围绕进程的创新进行展开讨论,评优作品

2021-01-13

燕山大学课程设计评优作品(页面置换算法)

燕山大学2018级操作系统课程设计评优作品,页面置换算法的实现,其中包括课程设计书,源码,答辩PPT。该项目实现的功能包括多种页面置换算法(FIFO,LRU,OPT)页面置换算法的动态显示,各类参数的设定,实验结果的图表显示以及保存。

2021-01-13

C#winform利用windows api实现U盘管理(检测,容量信息,禁用,开启,复制删除文件,获取pcb信息)

利用C#中的winform开发的U盘管理小项目,实现对U盘的检测,显示容量信息,禁用、开启U盘,复制删除文件,获取pcb信息,C#对这些操作都有很好的封装,但是本项目是为了体验windows api所以完全没有使用这些封好的东西,这些功能都是通过调用windows api实现的。

2020-11-13

空空如也

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

TA关注的人

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