随笔分类 -  / 算法

摘要:区间dp。 转移方程见题解(doge) #include<bits/stdc++.h> using namespace std; int m[310],dp[310][310],ans; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cou 阅读全文
posted @ 2024-10-11 20:36 yzc_is_SadBee 阅读(18) 评论(0) 推荐(0)
摘要:模板区间dp. 懒癌,于是把石子合并copy了一下。 #include<bits/stdc++.h> using namespace std; int m[310],dp[310][310],anss,ans; int main() { ios::sync_with_stdio(0); cin.ti 阅读全文
posted @ 2024-10-11 19:58 yzc_is_SadBee 阅读(10) 评论(0) 推荐(0)
摘要:简单四维dp。 #include<bits/stdc++.h> using namespace std; int a[355],b,t[5],dp[45][45][45][45]; int main(){ ios::sync_with_stdio(0); cin.tie(NULL); cout.ti 阅读全文
posted @ 2024-10-11 19:13 yzc_is_SadBee 阅读(7) 评论(0) 推荐(0)
摘要:补交。 #include<iostream> #include<cstdio> using namespace std; int g[105],f[105],a[105],s[105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a 阅读全文
posted @ 2024-10-11 18:29 yzc_is_SadBee 阅读(11) 评论(0) 推荐(0)
摘要:4维dp(因为n<=10) 就是二维dp+判断是否重复取 #include<bits/stdc++.h> using namespace std; int dp[15][15][15][15],a[15][15],x,y,z; int main() { ios::sync_with_stdio(0) 阅读全文
posted @ 2024-10-09 20:16 yzc_is_SadBee 阅读(10) 评论(0) 推荐(0)
摘要:没切 这题恶心的点死多…… 首先,你这数据不能一次性让我把bug改完吗?浪费lg评测资源,该罚 然后 进入正题 我踩的坑 两种机用同一个编号 中间会爆int,要在过程中就判掉 开头可能出现.这种毒瘤玩楞 然后比2023 csp-j T3 好写多了 #include<bits/stdc++.h> us 阅读全文
posted @ 2024-10-09 19:40 yzc_is_SadBee 阅读(9) 评论(0) 推荐(0)
摘要:交了锣鼓,但没交vjudge。 补交一下。 #include <iostream> using namespace std; void solve2(int n, int &y, int &m, int &d, bool flag) { static int todate[366][2]={{0,0 阅读全文
posted @ 2024-10-09 18:38 yzc_is_SadBee 阅读(6) 评论(0) 推荐(0)
摘要:dp 然而我们可以使用前缀和+暴搜,而且更好理解,同时复杂度约O(n2),能过 #include<bits/stdc++.h> using namespace std; int n,m,a[2505][2505],x[2505][2505],y[2505][2505],z[2505][2505],a 阅读全文
posted @ 2024-10-08 20:12 yzc_is_SadBee 阅读(12) 评论(0) 推荐(0)
摘要:终于想起来发博客了,呃呃呃呃呃呃 这题不难,但要看到 1≤L≤R<231和R−L≤106。 我们可以考虑先把<216的素数先筛出来,然后再把区间里的合数筛光。 然后……就没有然后了。 上代码: #include <bits/stdc++.h> #define int long long using 阅读全文
posted @ 2024-10-08 18:54 yzc_is_SadBee 阅读(7) 评论(0) 推荐(0)
摘要:又忘发博客了啊啊啊啊啊啊啊 马的遍历竟然现在才写…… 模板bfs。 #include<bits/stdc++.h> using namespace std; queue<int> _x,_y; int ma[405][405],dx,dy; int qx[8]={1,1,2,2,-1,-1,-2,- 阅读全文
posted @ 2024-10-07 20:03 yzc_is_SadBee 阅读(11) 评论(0) 推荐(0)