自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 |DS线性表的顺序存储_顺序表|静态数组&动态分配

线性表的基本操作: InitList(&L):初始化表,构造1个空的线性表 ListInsert(&L,i,e):插入操作,在表L的第i个位置插入指定元素e ListDelete(&L,i,&e):删除操作,删除表中第i个位置的元素,并用e返回删除元素的值 GetElem(L,i):按位查找操作,获取表中第i个位置上的元素的值 LocateElem(L,e):安置查找操作,在表L中查找具有给定关键字值得元素 PrintList(L):输出操作,按前后顺序输出线性表L的所有元.

2021-03-16 16:29:29 624

原创 |后序中序=>先序层序|1020 Tree Traversals (25 分)

link refer #include <iostream> #include <vector> #include <map> using namespace std; vector<int>post,in; map<int, int>level; void pre(int root,int inL,int inR,int index) { if (inL > inR)return; int r_; for (r_ = inL; r

2021-02-04 22:11:01 531

原创 |先序中序=>后序|17秋第三题 1138 Postorder Traversal

link #include <iostream> #include <vector> using namespace std; vector<int>pre; vector<int>in; vector<int>post; void postOrder(int root,int inL,int inR) { if (inL > inR)return; int r_; for (r_ = inL; r_ <= inR; r_

2021-02-04 21:23:50 524

原创 |图 并查集|19春第三题1158 Telefraud Detection (25分)

/* /**/ #include <iostream> #include <vector> #include <algorithm> using namespace std; int const maxn = 1010; int k, n, m; int G[maxn][maxn]; vector<int>v_suspect; int father[maxn]; vector<int>gang[maxn]; void find_susp

2021-02-04 00:03:28 461 1

原创 |连通图? 最强连通图? |17秋第三题 1142 Maximal Clique (25分)

#include <iostream> #include <vector> #include <algorithm> using namespace std; int const maxn = 1010; int n, m; int G[maxn][maxn] = { 0 }; vector<int>v; int check() { for (int i = 0; i < v.size(); i++) { for (int j = i +

2021-02-01 23:08:03 191

原创 |加顶点判断图的连通性-有边|19冬第三题1166 Summit (25分) 1142

//判断强连通图,如果是, //////////////再判断不在给定节点里的节点,有没有加进来依然属于强连通图的。 //题目规模很小,用邻接矩阵比较方便。 //每一组方案用bool变量来保存确定的判断结果以及及时break。 #include <iostream> #include <vector> #include <algorithm> using namespace std; int const maxn = 1010; int n, m; int G[maxn

2021-02-01 21:58:25 225

原创 |结构体的构造&初始化 tolower小写函数 遍历map 先rank后输出|17冬第二题1141 Ranking of Institutions

//20/25 //TTL #include <iostream> #include <map> #include <vector> #include <algorithm> using namespace std; struct SCHOOL { string school; int score; int num; int rank; SCHOOL(string a,int b,int c) { school =a; score = b

2021-01-31 20:28:25 182

原创 |排序|17秋第二题 1137Final Grading (25分)

#include <iostream> #include <map> #include <algorithm> using namespace std; struct Stu { string id; int ps, ms, fs; int G; bool valid; }stu[10010]; map<string, int>id_index; bool cmp(Stu a, Stu b) { if (a.G != b.G )return a

2021-01-30 22:34:54 174

原创 |链表|17春第二题1133 Splitting A Linked List(25分)

#include <iostream> #include <vector> using namespace std; int const maxn = 1000010; struct Node { int address, data, next; }node[maxn]; vector<Node>v,ans; int main() { int s, n, k; cin >> s >> n >> k; for (i...

2021-01-30 22:33:01 176

原创 |vector结构体排序 STL|18冬第二题1153 Decode Registration Card of PAT (25分)

link //19/25 #include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> using namespace std; struct Card { string id; int score; int times; }; vector<Card>v,v1,v

2021-01-29 22:32:56 173

原创 |reverse(v1.begin(),v2.end())&swap(v1,v2)&块数&next不同的第j块|19秋-1161-Merging Linked Lists (25 分)

链表存在vector里,不用再通过order来cmp来排序了 reverse(v1.begin(),v1.end()) swap(v1,v2) #include <iostream> #include <vector> using namespace std; int const maxn = 100010; struct Node { int address, data, next; int order; }node[maxn],node1[maxn],node2[ma..

2021-01-29 20:51:22 247

原创 |链表 倒块输出|19冬第二题1165 Block Reversing (25分) 跟1133类似的题目

#include <iostream> #include <algorithm> using namespace std; int const maxn = 100010; struct Node { int address,data,next; int order; }node[maxn]; bool cmp(Node a,Node b) { return a.order < b.order; } int main() { for (int i = 0;...

2021-01-28 22:03:00 221

原创 |*关于等价无穷小的使用 洛必达|day10

2021-01-28 20:26:29 1096 1

原创 |素数判断 while|19春第一题1156 Sexy Primes (20 分)

#include <iostream> using namespace std; bool isP(int n) { if (n <= 1)return false; for (int i = 2; i <=sqrt(n); i++) { if (n % i == 0) return false; } return true; } int isSexyPrime(int n) { if (isP(n) == true) { if (isP(n - 6)

2021-01-27 21:21:44 226

原创 |浮点错误/0 int2^32-1|17春第一题 1132 Cut Integer (20分)

link #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string s; cin >>s; int k = s.length() / 2; string a = s.substr(0, k); string b = s.sub

2021-01-27 20:39:31 172

原创 |夹逼准则 单调有界准则捷径|day9

2021-01-27 19:32:22 438

原创 |*洛必达法则求函数极限|day8

2021-01-27 19:31:14 378

原创 |cos2x=2cosx^2-1|day7

2021-01-27 19:30:31 646

原创 |函数相乘分离 函数增长速度|day6

2021-01-27 19:28:01 215

原创 |reverse 大数(字符串)相加|17年秋季第一题 1136 A Delayed Palindrome (20分)

link #include <string> #include <iostream> #include <algorithm> using namespace std; string add(string s,string reverse_s) { //97152 + 25179 = 122331 int jw = 0; string ans=""; for (int i = s.length() - 1; i >= 0; i--) { int tmp

2021-01-27 11:49:54 177

原创 |快慢指针 定位不重复元素下标|17冬第一题1140Look-and-say Sequence (20分)

link #include<iostream> #include<string> using namespace std; int main() { string s; int n; cin >> s >> n; while (--n) { string tmp; int i, j;//2个指针 //1121 for (i = 0; i < s.length(); i = j) { //i=0 //i=2 //i

2021-01-27 10:12:28 151

原创 |快慢指针 定位不重复元素下标|删除排序数组中的重复项

/* //不是原地//直接删除不同的元素 #include <iostream> #include <vector> using namespace std; vector<int>v; int main() { int n;//3//10 cin >> n; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; v.push_back(tmp);//1 1 2//0.

2021-01-27 10:09:44 187

原创 |素数判断&stoi字符串转int&str.substr(index,length)&第一个break|18冬第一题1152 Google Recruitment (20分)

link #include <iostream> #include <cstring> #include <string> #include <cmath> using namespace std; bool isprime(string s) { int n = stoi(s); if (n == 1)return false; for (int i = 2; i <=sqrt(n); i++) { if (n % i == 0)

2021-01-26 21:44:32 178

原创 |贪心 合成大西瓜(x)|1125 Chain the Ropes (25分)

1125 Chain the Ropes (25分) #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int>v; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int l; cin >> l; v.push

2021-01-25 22:02:03 1131

原创 贪心|1113 Integer Set Partition (25分)

1113 Integer Set Partition (25分) #include <iostream> #include <vector> #include <algorithm> using namespace std; int MIN = 100000000; int min_n = 100000000; vector<int>v; int n; int main() { cin >> n; for (int i = 0; i &lt

2021-01-25 21:23:41 141

原创 |动态二维数组vector遍历 set find|1149 Dangerous Goods Packaging (25分)

link #include <iostream> #include <vector> #include <set> using namespace std; int const maxn = 100010; vector<int>v[maxn]; set<int>s; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) {

2021-01-25 20:31:51 157

原创 |set 遍历|1144 The Missing Number (20分)

1144 The Missing Number (20分) //19 #include <iostream> #include <set> using namespace std; set<int>s; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; s.insert(tmp); } set<in

2021-01-24 22:45:43 120

原创 |map 赋值 遍历 vis %05d|1121 Damn Single (25分)

1121 Damn Single (25分) #include <map> #include <iostream> #include <vector> #include <set> using namespace std; int const maxn = 100000; map<int,int>cp; set<int>s; set<int>ss; int vis[maxn] = { 0 }; int main() {

2021-01-24 22:17:55 155

原创 |set 升序 各位数相加|1120 Friend Numbers (20分)

1120 Friend Numbers (20分) #include <cstdio> #include <iostream> #include <set> #include <algorithm> using namespace std; set<int>s; int cntSum(int a) { int sum = 0; while (a!=0) { sum += a % 10; a /=10; } return sum;

2021-01-24 21:15:22 142

原创 |贪心 大于小于需求|1070 Mooncake (25分)

link #include <iostream> #include <vector> #include <algorithm> using namespace std; struct M { double t,p,u; }m[100010]; //vector<M>v; bool cmp(M a,M b) { return a.u>b.u; } int main() { int typeN, demandTon; cin >&gt

2021-01-23 23:26:10 175

原创 1038 |贪心 排序 字符串最小 前导0去除|Recover the Smallest Number (30分)

link #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<string>vs; bool cmp(string a,string b) { return a + b < b + a; } int main() { int n; cin >> n; for (int i = 0; i < n;

2021-01-23 22:39:02 156

原创 |贪心 排序|1037 Magic Coupon (25分)

link // 不是所有的都要被购买,可以不买 #include <iostream> #include <vector> #include <algorithm> using namespace std; int nc, np; vector<int>vc; vector<int>vp; bool cmp(int a,int b) { return a > b; } int main() { cin >> nc; f

2021-01-23 21:14:40 164

原创 |贪心|1033 To Fill or Not to Fill (25分)

link refer /* 50 1300 12 8 6.00 1250 7.00 600 7.00 150 7.10 0 7.20 200 7.50 400 7.30 1000 6.85 300 */ #include <iostream> #include <vector> #include <algorithm> using namespace std; int const INF = 1000000000; int const maxn = 510; st

2021-01-22 22:27:19 130

原创 |hash 散列字符串 不要|1084 Broken Keyboard (20分)

link //7_This_is_a_test //_hs_s_a_es #include <string> #include <iostream>; using namespace std; int const MAXN = 100010; int hashTable[MAXN] = { 0 }; int vis[MAXN] = { 0 }; int main() { string s1, s2; getline(cin, s1); getline(cin, s2);

2021-01-21 20:24:21 146

原创 |hash 散列字符串 要|1092 To Buy or Not to Buy (20分)

link #include <string> #include <iostream> using namespace std; int const MAXN = 100010; int hashTable[MAXN] = { 0 }; int miss = 0; int main() { string s1, s2; getline(cin, s1); getline(cin, s2); for (int i = 0; i < s1.length(); i++)

2021-01-21 19:51:28 127

原创 |hash 散列字符串 不要|1050 String Subtraction (20分)

link //int不用也行 #include <iostream> #include <string> using namespace std; int const MAXN = 10010; int hashTable[MAXN] = { 0 }; int main() { string s1, s2; getline(cin,s1); getline(cin, s2); for (int i = 0; i < s2.length(); i++) { h

2021-01-20 22:09:03 129

原创 |hash 散列|1048 Find Coins (25分)

link //TLE //20/25 // #include <iostream> // #include <vector> // #include <algorithm> // using namespace std; // vector<int>v; // vector<int>ans; // int main() { // int n, m; // cin >> n >> m; // for (int i =

2021-01-20 21:36:47 129

原创 |dfs|1103 Integer Factorization (30分)

link //dfs()莫名的和树的遍历很像 //先序:存入根、访问左孩子、访问右孩子 //dfs():选(访问当前fac[index])、不选(访问fac[index-1]) #include <iostream> #include <vector> #include <cmath> using namespace std; int N, K, P; //169 5 2 vector<int>fac, temp, ans; int maxFacSum =

2021-01-14 10:28:11 131

原创 静态链表解题步骤

2021-01-13 15:54:16 170

原创 |静态链表|(21/25)1074 Reversing Linked List (25分)

link /* 00100 6 3 00000 4 99999 00100 1 12309 68237 6 -1 33218 3 00000 99999 5 68237 12309 2 33218 */ #include <iostream> #include <algorithm> using namespace std; const int maxn = 100010; struct Node {//1 int address,data,next; int orde

2021-01-13 14:58:50 153

空空如也

空空如也

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

TA关注的人

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