随笔分类 -  基础算法刷题记录

摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> using namespace std; typedef long long ll; void charge(ll r, ll n) { if (n == 0) { cout << 0 << e 阅读全文
posted @ 2020-03-11 01:36 暮云林凌 阅读(167) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> using namespace std; void charge(int n) { string res = ""; if (n == 0) { cout << 0 << endl; retur 阅读全文
posted @ 2020-03-11 01:26 暮云林凌 阅读(180) 评论(0) 推荐(0)
摘要:基本思想: 如果采用补全,可以有效减少长度; 关键点: 无; #include<iostream> #include<vector> #include<string> #include<sstream> #include<algorithm> using namespace std; vector< 阅读全文
posted @ 2020-03-11 01:17 暮云林凌 阅读(154) 评论(0) 推荐(0)
摘要:基本思想: 其实如果只有空格完全可以stringstream来做; 关键点: 无; #include<iostream> #include<vector> #include<string> #include<sstream> using namespace std; int main() { str 阅读全文
posted @ 2020-03-11 00:19 暮云林凌 阅读(147) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<sstream> using namespace std; vector<string>vec; int main() { string s; 阅读全文
posted @ 2020-03-10 23:52 暮云林凌 阅读(157) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<set> using namespace std; const int maxn = 400; vector<int> num[maxn]; 阅读全文
posted @ 2020-03-10 23:04 暮云林凌 阅读(183) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; const int maxn = 90; bool flag[maxn]; i 阅读全文
posted @ 2020-03-10 19:40 暮云林凌 阅读(125) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; struct node { int x; int y; }; node num 阅读全文
posted @ 2020-03-10 19:29 暮云林凌 阅读(109) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<string> #include<iostream> #include<vector> #include<algorithm> using namespace std; struct mouse { int weight; string color 阅读全文
posted @ 2020-03-10 18:57 暮云林凌 阅读(147) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main(){ int a[10] = {0}; int b[10] = {0}; while ( 阅读全文
posted @ 2020-03-10 18:09 暮云林凌 阅读(170) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<set> #include<algorithm> using namespace std; int main() { int n; while 阅读全文
posted @ 2020-03-10 11:34 暮云林凌 阅读(183) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> using namespace std; double p1 = 5; double p2 = 3; double p3 = 1.0 / 3; void cha 阅读全文
posted @ 2020-03-10 11:03 暮云林凌 阅读(129) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> using namespace std; bool charge(int n) { if (n % 7 == 0) return true; while (n 阅读全文
posted @ 2020-03-10 10:38 暮云林凌 阅读(138) 评论(0) 推荐(0)
摘要:基本思想: 被递归搞怕了,其实循环打表都可以,提前打表复杂度更低一点; 关键点: 无; #include<iostream> #include<vector> using namespace std; const int maxn = 31; int num[maxn]; void init() { 阅读全文
posted @ 2020-03-09 14:24 暮云林凌 阅读(115) 评论(0) 推荐(0)
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<vector> using namespace std; const int maxn = 1000000010; int cnt; void fun(int index,int n) { if (index 阅读全文
posted @ 2020-03-09 14:15 暮云林凌 阅读(189) 评论(0) 推荐(0)
摘要:基本思想: 还是在注意一下,最大公因数和质因子没啥关系,最大公因数可以是合数; 最大公因数求法:辗转相除; 最小公倍数求法:m*n/最大公因数; 关键点: 无; #include<string> #include<iostream> #include<vector> using namespace 阅读全文
posted @ 2020-03-09 14:06 暮云林凌 阅读(192) 评论(0) 推荐(0)
摘要:基本思想: 快速幂取模,如果不去模,就是快速幂大数问题; 关键点: 无; #include<iostream> #include<string> using namespace std; typedef long long ll; string s; //int f[maxn]; void mult 阅读全文
posted @ 2020-03-09 12:54 暮云林凌 阅读(190) 评论(0) 推荐(0)
摘要:基本思想: 自己想用dfs方式来进行遍历,但是发现找不到剪枝的方向,只能确定边界,状态无序; 如果采用递归的方法,可以进行问题分解; 本质上就是n个有序圆盘,相当于分解为以下几步: 1.将n-1个有序圆盘原封不动移到第三根杆子处; 2.将第n个最大盘子移到第二位; 3.把n-1个有序圆盘原封不动移回 阅读全文
posted @ 2020-03-09 12:02 暮云林凌 阅读(270) 评论(0) 推荐(0)
摘要:基本思想: 老生常谈的问题,这种阶乘主要考察溢出。 用大数、long long、double可以解决; 关键点: 无; #include<iostream> #include<vector> #include<string> #include<algorithm> using namespace s 阅读全文
posted @ 2020-03-09 02:00 暮云林凌 阅读(266) 评论(0) 推荐(0)
摘要:基本思想: 崩溃了,主要还是有两个问题: 1.存在剪枝问题,不剪枝会超时; 2.DFS写法的问题,感觉OJ里特别喜欢通过返回true false,来进行多循环的一次递归解决所有问题; bool dfs(int n,int index,int value,int num) { if (num == 3 阅读全文
posted @ 2020-03-09 00:56 暮云林凌 阅读(145) 评论(0) 推荐(0)