上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 45 下一页
摘要: 二分计数 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #define For(i, j, n) for(int i = j ; i <= n ; ++i) using namespace 阅读全文
posted @ 2024-02-13 23:24 Gold_stein 阅读(40) 评论(0) 推荐(0)
摘要: 这份代码开了O2会WA和RE,但不开的话又会因为STL速度太慢而TLE #include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <string> #include <vector> # 阅读全文
posted @ 2024-02-10 13:37 Gold_stein 阅读(44) 评论(0) 推荐(0)
摘要: 这种题目要注意: 1.输入 因为所有的格式都很明确,所以可以用scanf写一个输入格式,同时注意空格和回车 2.怎么简化计算 可以把所有时间都转换成秒进行计算,最后再转换回标准格式,这样可以避免考虑进位,借位,以及浮点数精度问题 #include <bits/stdc++.h> using name 阅读全文
posted @ 2024-01-26 16:10 Gold_stein 阅读(36) 评论(0) 推荐(0)
摘要: 贪心,把钱最多的放在后面兜底,前面的能付多少付多少 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <math.h> #define For(i, j, n) for (in 阅读全文
posted @ 2024-01-24 16:51 Gold_stein 阅读(50) 评论(0) 推荐(0)
摘要: 又是一道和取模有关的最值问题,因为原问题的规模太大,因此我们可以存储数字取模后的值 最极端的情况就就是三个模k同余的数字相加得到答案,因此每个剩余类只要存三个数字即可 #include <iostream> #include <stdio.h> #include <algorithm> #inclu 阅读全文
posted @ 2024-01-22 14:12 Gold_stein 阅读(42) 评论(0) 推荐(0)
摘要: 这道题可以用类似单调队列的思路实现,因为其本质上是一个滑动窗口,虽然有两重循环,但是因为i和j是总的N被分摊之后的数字,所以真实的时间复杂度依然是O(N) #include <iostream> #include <stdio.h> #include <algorithm> #include <st 阅读全文
posted @ 2024-01-21 00:15 Gold_stein 阅读(53) 评论(0) 推荐(0)
摘要: 这道题虽然逻辑很简单,但是坑不少,一不留神就WA了 要记得去重+排序 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #include <set> #define For(i, j, n) f 阅读全文
posted @ 2024-01-20 18:58 Gold_stein 阅读(62) 评论(0) 推荐(0)
摘要: 可以把这道题看成一个只有 一种运算符的表达式求值 #include <iostream> #include <stdio.h> #include <algorithm> #include <string> #define For(i, j, n) for(int i = j ; i <= n ; + 阅读全文
posted @ 2024-01-17 17:30 Gold_stein 阅读(31) 评论(0) 推荐(0)
摘要: 注意要把map[0]设置为1,因为根据题意,长度为1 的区间也要算进来 完整代码: #include <iostream> #include <map> #define int long long using namespace std; map <int, int> mp; //记录每个余数出现个 阅读全文
posted @ 2024-01-11 22:30 Gold_stein 阅读(57) 评论(0) 推荐(0)
摘要: 1.首先想到的错解 看到数据范围,就想先写个n^2的暴力:先把所有矩形的面积都算出来,然后再把所有重合的部分挨个减去,把每个重合的部分当成一个个小矩形,用set来判重。 画一个稍复杂些的样例,就会发现,在这些由重合部分产生的小矩形之间,仍有重合,所以这种算法,会导致算出来的重合部分偏大,而导致最后的 阅读全文
posted @ 2023-12-26 12:44 Gold_stein 阅读(77) 评论(1) 推荐(1)
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 45 下一页