自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 杭电oj 1232 畅通工程 (并查集)

#include <iostream>#define rep(i,a,b) for (int i=a;i<b;i++)using namespace std;const int N=500005;int n,m;int pre[N];int street;int find(int x)//查找每个node的根节点{ int r = x; while(pre[r]!=r) r = pre[r]; int i=x , j ; while( i != r )/.

2021-11-30 10:38:36 246

原创 杭电oj 1312 Red and Black (dfs)

类似于迷宫问题#include<iostream>using namespace std;char map[105][105];int n,m;int sum=0;int direction[4][2]{ {0,1}, {1,0}, {0,-1}, {-1,0}};//控制走的方向void dfs(int x,int y){ if(map[x][y]=='#')//走到'#'的地方返回 return ; sum++;//增加点的个数 map[x][y]=.

2021-11-22 21:11:23 463

原创 杭电oj 1241 Oil Deposits(dfs)

#include<iostream>using namespace std;int n,m;char map[105][105];int place[8][2]={ {1,0}, {1,1}, {1,-1}, {0,-1}, {0,1}, {-1,0}, {-1,1}, {-1,-1}};//用于搜索八个方位void dfs(int i,int j){ map[i][j]='*'; for(int k=0;k<8;k++) {.

2021-11-22 09:22:49 106

原创 杭电oj 1003 Max Sum (动态规划,dp)

#include<iostream> using namespace std; typedef struct dp{ int place, val;};int main(){ int t; cin>>t; for(int j=0;j<t;j++) { int n, a[100005]; dp dp[100005]; cin>>n; for (int i = 0; i < n; i++) cin>>a[.

2021-11-18 14:11:11 356

原创 杭电oj 1203 I NEED A OFFER(01背包问题)

Problem DescriptionSpeakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能性b。不同学校之间是否得到offer不会互相影响。“I NEED A OFFER”,

2021-11-17 14:33:23 164

原创 快速排序:三数取中+插排+聚集相等元素

三数取中:作为枢纽 防止卡时间复杂度插排:排序个数少时可以优化时间复杂度聚集相等元素:减少重复排序的时间浪费#include<iostream>using namespace std;int array[100005];int arr[1000005]={0};/*函数作用:取待排序序列中low、mid、high三个位置上数据,选取他们中间的那个数据作为枢轴*/ int SelectPivotMedianOfThree(int arr[],int low,int hi.

2021-11-17 12:32:47 428

原创 杭电oj 2031 进制转换

#include<iostream>#include<cmath>#include<algorithm>#include<string>using namespace std;int max(int n, int m)//求答案的位数 即m的最高次-1{ double num; for(int i=0;;i++) { num=pow(m,i); if(num>n) return i-1; }}int main(){.

2021-11-17 12:19:27 299

原创 杭电oj 2091 空心三角形(小心PE)

格式是输出三角形、输入数据、空一行,而不是输出三角形后空一行。且第一次输入不换行。#include<iostream>using namespace std;int main(){ char a; int flag=0; while((a=getchar())!='@') { int n; cin>>n; if(flag!=0) cout<<endl;//flag=0时不换行,但后来输入要换行而

2021-11-16 18:37:39 449

原创 杭电oj 2072 单词数

#include<iostream>#include<set>#include<string>using namespace std;int main(){ string s; while(getline(cin,s)) { if(s=="#") return 0; set<string>v; string stream; s=" "+s.

2021-11-16 17:56:42 606

原创 杭电oj 2081 手机短号(C++)

#include<iostream>#include<string>using namespace std;int main(){ int t; cin>>t; while(t--) { string s; cin>>s; cout<<"6"+s.substr(6,5)<<endl; } return 0;}

2021-11-16 17:53:33 690

空空如也

空空如也

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

TA关注的人

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