摘要: 背包与魔法 01背包的变形 因为只能用一次魔法就多加一维1表示用了魔法 0表示没用魔法 #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define inf 1e18 cons 阅读全文
posted @ 2024-04-09 23:51 xde_yt 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 翻转后1的数量 最重要的还是状态的设置,多积累吧 #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define inf 1e18 const int N = 1e5 + 10; 阅读全文
posted @ 2024-04-09 23:45 xde_yt 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 数组切分 #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" /* 1 3 2 4 1: {1}dp[1]+=dp[0] 2: {1}{3}dp[2]+=dp[0] 3: {1}{3 阅读全文
posted @ 2024-03-24 16:18 xde_yt 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 选数异或 #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" const int N = 1e5 + 10,mod = 998244353; int n, x; int dp[N][ 阅读全文
posted @ 2024-03-22 13:38 xde_yt 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 安全序列 #include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" const int N = 1e6 + 10,mod = 1e9 + 7; int n, k; int dp[N]; v 阅读全文
posted @ 2024-03-22 12:43 xde_yt 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 数字排列 /* 先找规律,根据题目要求的前面的数字尽可能大,从第一位开始试数字,从20-1尝试,可以找到以下序列,并观察出规律 20 19 20 18 20 19 20 17 20 19 20 18 20 19 20 17 20 19 20 18 20 19 20 20 19 20 18 20 19 阅读全文
posted @ 2024-03-22 11:05 xde_yt 阅读(0) 评论(0) 推荐(0) 编辑
摘要: 数组分割 /*dp[N][2] dp[i][0]表示选到前i个数,和为偶数的方案数 dp[i][1]表示选到前i个数,和为奇数数的方案数 由于偶=偶+偶 偶=奇+奇 奇=奇+偶 当a[i]为偶数时 dp[i][0] += dp[i-1][0] + dp[i-1][0],dp[i][1] += dp[ 阅读全文
posted @ 2024-03-22 11:04 xde_yt 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 23年蓝桥省赛 A.日期统计 赛时好像没写出来?还是咋写的来着我忘了,反正这个解法挺妙的,枚举每一天的日期,因为题目限制了2023的日期且每种日期只计算一次。 #include<bits/stdc++.h> using namespace std; #define endl "\n" #define 阅读全文
posted @ 2024-03-20 00:07 xde_yt 阅读(3) 评论(0) 推荐(0) 编辑
摘要: Problem L. Spicy Restaurant 题意: 无向图的每个顶点有一个属性 w i w_i wi​, Q Q Q 个询问,第 i i i 个询问给定顶 点 p p p 和阈值 a a a,问距离 p p p 最近的 w i ≤ a w_i \leq a wi​≤a 的 i i i 距 阅读全文
posted @ 2023-12-15 12:19 xde_yt 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 五、数论 文章目录 五、数论快速幂矩阵快速幂矩阵快速幂加速递推最大公约数和最小公倍数埃式筛法 O ( n l o g l o g ( n ) ) O(nloglog(n)) O(nloglog(n))欧式筛法 O ( n ) O(n) O(n)欧拉函数线性欧拉函数约数定理**费马小定理**欧拉定理威 阅读全文
posted @ 2023-12-14 10:51 xde_yt 阅读(4) 评论(0) 推荐(0) 编辑