07 2023 档案
摘要:题解: 这道题的关键是找到状态转移方程,从最底层(n)开始,计算上面全部(n, n - 1, n - 2 …… 1)层的总表面积和总体积,从而来确定使表面积最小的S 1 #include <bits/stdc++.h> 2 using namespace std; 3 #define S(r) ((
阅读全文
摘要:题解: 这段代码实现了一个递归的记忆化搜索算法,用于解决一个求最大蛋糕面积下限的问题。下面解释一下其递归思路: 定义状态 设 ways[w][h][m] 表示当前蛋糕的宽度为 w,高度为 h,已经切了 m 刀时,最大蛋糕面积的下限。 状态转移 对于当前的蛋糕,可以选择竖着切一刀或者横着切一刀。竖着切
阅读全文
摘要:题解: 1 #include <bits/stdc++.h> 2 using namespace std; 3 const double ex = 1e-6; 4 double a[5]; 5 bool iseq(double a, double b) 6 { 7 return fabs(a - b
阅读全文
摘要:题解: 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <vector> 7 #include <map> 8 #i
阅读全文
摘要:题解: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 string init, result; // 要操作的,预期的 7 string temp; // 记录当前状态 8 cin >> init >>
阅读全文
摘要:题解: 思路:将A~L每个字母都枚举一遍(每个字母都有轻和重两种状态),看看是否符合输入数据条件 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 string Left[3], Right[3], Result[3]; 5 6 bool c
阅读全文
摘要:记忆化搜索 ——即把搜过的地方记录下来,后面再搜的时候直接取就好了 题解: 1 #include <iostream> 2 using namespace std; 3 #define ll long long 4 const int N = 100; 5 ll a[N], n; 6 ll dfs(
阅读全文
摘要:题解: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 bool d[100]; // 记录棋盘主对角线能否放 5 bool c[100]; // 副对角线 6 bool b[20]; // 列 7 8 int a[20]; 9 10 //
阅读全文
摘要:题解: 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cmath> 5 #include <cstring> 6 #include <vector> 7 #include <map> 8 #i
阅读全文
摘要:这道题真是费了我好大力气(估计我还会回来看不少次qwq) 题解(DFS): 每个钟有4种情况,暴力枚举49种情况,这里只要一维数组就可以记录钟的状态(nowClock[] 和 oriClock[]) 1 #include <bits/stdc++.h> 2 using namespace std;
阅读全文
摘要:题解: 一条路走到头,然后再回头 vis数组来标记已走过的点,a数组来存数字 1 #include <bits/stdc++.h> 2 using namespace std; 3 int n; 4 bool vis[20]; 5 int a[20]; 6 7 void dfs(int x) 8 {
阅读全文
摘要:题解: 这道题重点是行号和列号 !千万! 别搞反了,还有就是用dx 和 dy数组表示顺时针转动 1 dx = [-1, 0, 1, 0] 2 dy = [0, 1, 0, -1] 3 n, m = map(int, input().split()) # n行m列 4 x, y, d = 0, 0,
阅读全文
摘要:二进制密码锁 描述: 在海拉鲁大陆有一种特殊的二进制密码锁,由n个相连的按钮组成(n<30),按钮有凹/凸两种状态,用手按按钮会改变其状态。 然而让人头疼的是,当按一个按钮时,跟它相邻的两个按钮状态也会反转。当然,如果按的是最左或者最右边的按钮,该按钮只会影响到跟它相邻的一个按钮。 当前密码锁状态已
阅读全文