摘要:
https://www.acwing.com/problem/content/3235/ 水题。 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int main(void){ 5 int n; 6 cin>>n; 7
阅读全文
posted @ 2021-03-26 09:40
greenofyu
阅读(28)
推荐(0)
摘要:
https://www.acwing.com/problem/content/3206/ 水题。 1 #include<iostream> 2 using namespace std; 3 bool st[110][110]; 4 int main(void){ 5 int n; 6 cin>>n;
阅读全文
posted @ 2021-03-26 09:39
greenofyu
阅读(50)
推荐(0)
摘要:
https://www.acwing.com/problem/content/3211/ 直接看成两个三角形(略显复杂) 1 #include<iostream> 2 using namespace std; 3 const int N=500; 4 int a[N][N]; 5 int main(
阅读全文
posted @ 2021-03-26 09:38
greenofyu
阅读(78)
推荐(0)
摘要:
https://www.acwing.com/problem/content/903/ 记忆化搜索经典题目,滑雪。 只能从高的地方往低的地方滑,问最多能滑多少个点。 如果这个方程用循环来写的话,听说会非常非常麻烦(反正我不会) 所以就有了记忆化搜索。 1 #include<iostream> 2 #
阅读全文
posted @ 2021-03-24 19:13
greenofyu
阅读(18)
推荐(0)
摘要:
A:水题,数据范围较小,直接暴力模拟。 1 class Solution { 2 public: 3 bool check(vector<int> a,int i,int j ){ 4 for(int k=i+1;k<=j;k++){ 5 if(a[k]<=a[k-1]){ 6 return fal
阅读全文
posted @ 2021-03-23 20:17
greenofyu
阅读(20)
推荐(0)
摘要:
https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/ 逆波兰表达式也就是后缀表达式,直接通过栈即可求出答案。 难的不是逆波兰表达式的求值,难的是将中缀表达式转化为后缀表达式。 1 class Solution { 2 p
阅读全文
posted @ 2021-03-23 13:18
greenofyu
阅读(36)
推荐(0)
摘要:
A:枚举所有可能的情况,判断能否组成两个三角形。 1 #include<iostream> 2 #include<vector> 3 using namespace std; 4 bool three_one(int a){ 5 int cnt0=0,cnt1=0; 6 for(int i=0;i<
阅读全文
posted @ 2021-03-21 10:30
greenofyu
阅读(46)
推荐(0)
摘要:
https://www.acwing.com/problem/content/287/ 所谓树形DP,也就是关系的两边变成了树的上层和下层。 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 const int N=6
阅读全文
posted @ 2021-03-20 18:29
greenofyu
阅读(38)
推荐(0)
摘要:
A:水题,给定两个字符串,问能否只交换一次使得两字符串相等。 解法1:记录两字符串不相等的位置。 1 class Solution { 2 public: 3 bool areAlmostEqual(string s1, string s2) { 4 int n=s1.length(); 5 int
阅读全文
posted @ 2021-03-15 17:43
greenofyu
阅读(47)
推荐(0)
摘要:
A:模拟题,每次进站加上应该要的时间和延迟的时间 每次等待的时候需要题给定的两个条件都满足。 注意:最后一站不需要等待,所以需要单独考虑。 1 #include<cstring> 2 #include<algorithm> 3 #include<iostream> 4 using namespace
阅读全文
posted @ 2021-03-14 22:51
greenofyu
阅读(38)
推荐(0)