蓝桥杯
mingyu19
这个作者很懒,什么都没留下…
展开
-
【背包问题】
2. 01背包问题/* f[i][j]: 放 第 i 个物品, 在体积不超过 j 的情况的最大 w f[i][j] = max(f[i - 1][j], f[i - 1][j - v[i]]);注意特判 结果: f[n][m]*/#include <bits/stdc++.h>using namespace std;const int N = 1010;int n, m;int v[N], w[N];int f[N][N];原创 2022-04-09 00:23:38 · 53 阅读 · 0 评论 -
【蓝桥杯 -二分加前缀和】
1227. 分巧克力730. 机器人跳跃问题1230. K倍区间1221. 四平方和1227. 分巧克力1227. 分巧克力#include <iostream>#include <cstring>#include <algorithm>#define x first#define y secondusing namespace std;const int N = 1e5 + 10;typedef pair<int, int&.原创 2022-04-08 19:20:55 · 200 阅读 · 0 评论 -
【论万能开头】
#include <bits/stdc++.h>带 map, set, vector, max, min, memset 等常用头文件原创 2022-04-08 12:05:27 · 68 阅读 · 0 评论 -
【蓝桥杯 - 0405 刷题统计】
#include <iostream>#include <cstring>#include <algorithm>#define tt int t; cin >> t; while(t -- ) run();using namespace std;const int N = 1e3 + 10;int get(int n){ if(n >= 1 && n <= 10) return 1; if(n.原创 2022-04-05 17:32:10 · 253 阅读 · 0 评论 -
【蓝桥杯-0404(动态规划)】
/* f[i][j] 存的是走到 [i, j] 这个位置 一共有多少种方案 f[i][j] = f[i - 1][j] + f[i][j - 1]*/#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 40;int f[N][N];int main(){ int n, m; cin .原创 2022-04-04 22:57:39 · 711 阅读 · 0 评论 -
【蓝桥杯-七段码】
//AC code#include<bits/stdc++.h>#define deb(x) cout << #x << "=" << x << endl#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl#define deb3(x, y, z) .原创 2022-04-03 21:23:38 · 595 阅读 · 1 评论 -
【蓝桥杯-0403 + 0405刷题统计】
1238. 日志统计#include <iostream>#include <cstring>#include <algorithm>#define x first#define y second#define deb(x) cout << #x << "=" << x << endl#define deb2(x, y) cout << #x << "=" << x <原创 2022-04-03 15:02:36 · 1045 阅读 · 0 评论 -
【蓝桥杯-分巧克力】
没有想到还有可以舍弃的巧克力#include <iostream>#include <cstring>#include <algorithm>#define x first#define y second#define deb(x) cout << #x << "=" << x << endl#define deb2(x, y) cout << #x << "=" <<..原创 2022-03-30 15:20:50 · 68 阅读 · 0 评论 -
【蓝桥杯-跑步练习】
无语了, 因为把判闰年 y % 400 == 0 写成了 y % 400 调了半小时// 枚举每一天, 典型的暴力模拟// 周一的表示方法: (sum + 5) % 7 == 1;#include <iostream>#include <cstring>#include <algorithm>using namespace std;int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31,..原创 2022-03-29 22:06:23 · 101 阅读 · 0 评论 -
【蓝桥杯-明码】
// 一行表示一个数, 一行32个数, 然后两个数组成这个字的一行// 故每两个数字 endl;#include <iostream>#define deb(x) cout << #x << "=" << x << endl#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y.原创 2022-03-29 21:09:32 · 83 阅读 · 0 评论 -
【蓝桥杯-质数】
这道题 线性筛 或者 埃氏筛法 都能过, 因为没有超过 10^6;#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 1e5 + 10;int primes[N];int cnt = 0;bool st[N];void get_primes(int n){ for(int i = 2; i &l...原创 2022-03-29 20:45:02 · 62 阅读 · 0 评论 -
【蓝桥杯-棋盘放麦子】
吐了, 被这道题坑了 40 分钟, 害~(1 + 2 + 4 + 8) -> 2**4 - 1;ULL 的最大范围如果直接用pow(2, 64) 到最后一个 64 的时候会爆 ull;综上: 选择累加法 -> 最后只用算到 2的(1, 63), 累加之后得出一个数, 然后加上第一个 1, 这样就不会爆了#include <iostream>#include <cstring>#include <algorithm>using ..原创 2022-03-29 19:40:34 · 311 阅读 · 0 评论 -
【蓝桥杯-递增三元组】
测试次数原创 2022-03-28 18:55:58 · 63 阅读 · 0 评论