摘要: A.CF1657D For Gamers. By Gamers. 推一下式子发现要求是$C/c*dh > DH$,所以先处理每个单位价格对应最大$dh$, 再更新每多买一个单位时的贡献,复杂度$nlogn$ #include <bits/extc++.h> #include <bits/stdc++ 阅读全文
posted @ 2022-03-26 23:38 lemu 阅读(80) 评论(0) 推荐(0) 编辑
摘要: A.P1127 词链 以字母为节点,单词为边建图,求无向图字典序最小的欧拉路径。 #include <bits/stdc++.h> #define fu(a, b, c) for (ll a = b; a <= c; a++) #define fd(a, b, c) for (ll a = b; a 阅读全文
posted @ 2022-03-07 11:21 lemu 阅读(97) 评论(0) 推荐(0) 编辑
摘要: A.CF489E Hiking 01分数规划,二分答案,$\sum a_i / \sum b_i ⇐ k \ \Rightarrow \sum a_i - k b_i ⇐ 0$,对于确定的$k$用dp判定。 #include <bits/extc++.h> #include <bits/stdc++ 阅读全文
posted @ 2022-02-04 03:13 lemu 阅读(53) 评论(0) 推荐(0) 编辑
摘要: A.P7998 猜数 对于一个区间$[L, R]\(中的询问\)[l, r]$交互库必然会让你能确定的区间为 \([L, r - 1]\),$[l + 1, R]$中的较长者。所以我们应当选取到端点距离相等的区间询问。 在此基础上dp,有 \(dp[i] = \min \limits_{i / 2 阅读全文
posted @ 2022-01-22 13:36 lemu 阅读(54) 评论(0) 推荐(0) 编辑
摘要: A/B. CF1614D1/D2 Divan and Kostomuksha $令dp[i]\(表示\)\max \sum_{i = 1}^{n} \gcd(a_1, a_2, ..., a_i), \ a_1, a_2, ..., a_i$是一个含有因数$i$的元素构成的重排序列, $cnt[i] 阅读全文
posted @ 2021-12-16 00:46 lemu 阅读(44) 评论(0) 推荐(0) 编辑
摘要: A.P1144 最短路计数 bfs,从样例中可以看出重边算不同路径,注意取模。 #include <bits/stdc++.h> #define fu(a, b, c) for (ll a = b; a <= c; a++) #define fd(a, b, c) for (ll a = b; a 阅读全文
posted @ 2021-12-02 14:53 lemu 阅读(53) 评论(0) 推荐(0) 编辑
摘要: A.P1103 书本整理 显然的dp,dp[i][j]代表前i本书留下j本的最优答案,答案为dp[n][n - k]。 #include <bits/stdc++.h> #define fu(a, b, c) for (ll a = b; a <= c; a++) #define fd(a, b, 阅读全文
posted @ 2021-11-18 23:31 lemu 阅读(67) 评论(0) 推荐(0) 编辑
摘要: A.P1066 2^k进制数 dp[i][j]表示最高位在i取j时的方案数,需要高精度,这里用py并滚动掉第一维逆序迭代 k, w = map(int, input().split()) l = pow(2, k) - 1 n = min((w + k - 1) // k, l) # 最长位数 m 阅读全文
posted @ 2021-11-04 22:03 lemu 阅读(53) 评论(0) 推荐(0) 编辑
摘要: A. P1084 [NOIP2012 提高组] 疫情控制 二分答案,倍增+贪心来check。 #include <bits/stdc++.h> #define fu(a, b, c) for (ll a = b; a <= c; a++) #define fd(a, b, c) for (ll a 阅读全文
posted @ 2021-10-23 23:35 lemu 阅读(57) 评论(0) 推荐(0) 编辑
摘要: A. CodeForces 1526D 由D题可以知道交换需要的次数就是目标字符串相对于原字符串的逆序对个数, 想让逆序对个数尽可能多那么相同字符要连在一起,所以只需要枚举全排列即可。 #include <bits/stdc++.h> #define fu(a, b, c) for (int a = 阅读全文
posted @ 2021-10-22 12:06 lemu 阅读(56) 评论(0) 推荐(0) 编辑
4