随笔分类 - 基础算法刷题记录
摘要:基本思想: PAT一道同思想的题; 关键点: 无; #include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<set> #include<map> using n
阅读全文
摘要:基本思想: 提前打表,直接算; 关键点: 无; #include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<set> #include<map> using nam
阅读全文
摘要:基本思想: 无; 关键点: 无; #include<iostream> #include<vector> #include<algorithm> #include<string> #include<cmath> #include<set> using namespace std; int main(
阅读全文
摘要:基本思想: 想到贪心,但是觉得时间复杂度太高,结果一不小心写出来个更复杂的贪心; 关键点: 注意特殊用例,有可能无法遍历出正确结果,即没有切换得到正确的值,此时要避免进入死循环; #include<iostream> #include<vector> #include<algorithm> #inc
阅读全文
摘要:https://www.nowcoder.com/practice/04c8a5ea209d41798d23b59f053fa4d6?tpId=40&tqId=21334&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking 基本思想:
阅读全文
摘要:https://www.nowcoder.com/practice/0383714a1bb749499050d2e0610418b1?tpId=40&tqId=21333&tPage=1&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan/question-ranking 基本思想:
阅读全文
摘要:基本思想: 上三角判断,简单逻辑; 关键点: 无; #include<stdlib.h> #include<stdio.h> #define maxn 21 int n,num; int ma[maxn][maxn]; int charge(int n) { //判断是否是上三角 for (int
阅读全文
摘要:基本思想: 和三维矩阵的遍历类似,注意别超出数组大小; 关键点: 无; #include<stdlib.h> #include<stdio.h> #define maxn 21 int m,n; int index = 0; int ma[maxn][maxn]; int X[4] = { 0,1
阅读全文
摘要:基本思想: 注意一下副对角线使i+j=n的规律; 关键点: 无; #include<stdlib.h> #include<stdio.h> #define maxn 11 int n; int ma[maxn][maxn]; int main(){ int a; scanf("%d",&n); in
阅读全文
摘要:基本思想: 弱智题; 关键点: 无; #include<stdlib.h> #include<stdio.h> int m, n; int main(){ int a; scanf("%d %d", &m, &n); for (int i = 0; i < m; i++) { int sum = 0
阅读全文
摘要:基本思想: 平年365 2月28 不能被4整除; 闰年 366 2月29 能被4整除; 比如2020年,366天,二月二十九天; 关键点: 无; #include<stdlib.h> #include<stdio.h> #include<iostream> using namespace std;
阅读全文
摘要:基本思想: 直接计算,和7-3思想差不多; 关键点: 才发现自己侥幸逃脱的一个坑点:这题隐含了一个高阶阶乘的问题,如果贸然使用int来计算阶乘,会出现溢出问题; 后续总结一下; #include<stdlib.h> #include<stdio.h> #include<iostream> using
阅读全文
摘要:基本思想: 仍然是按照展开式的计算问题; 关键点: 无; #include<stdlib.h> #include<stdio.h> #include<iostream> using namespace std; double factor(double x) { if (x == 1.0) retu
阅读全文
摘要:基本思想: 按照公式逐项求和,最后对比给出的误差范围,确定求到第几步,是机试的一个典型题目; 关键点: 卡在了怎么输入指数浮点数的问题上,第一次件scanf("%le")中的le规格; 使用cin>>或者scanf("%le")其实都是可以输入1E-5作为浮点存储; 但是当时看内存踩坑里了,误以为1
阅读全文

浙公网安备 33010602011771号