Loading

摘要: 题目链接: https://www.acwing.com/problem/content/1240/ 题解: 双指针算法,注意率先移动前向的指针,当前向指针的时间-后向指针的时间超过了规定时间的话,后项指针要移动到该区间里才行 AC代码: #include <cstdio> #include <cs 阅读全文
posted @ 2020-02-28 19:15 Doubest 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1272/ 题解: 线段树模板题,单点求和、区间查询都可 AC代码: #include <cstdio> #include <iostream> #include <algorithm> #include <c 阅读全文
posted @ 2020-02-16 22:03 Doubest 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/description/1266/ 题解: 模板题,记query()、add()、lowbit()函数即可 AC代码: #include <iostream> #include <cstdio> #includ 阅读全文
posted @ 2020-02-16 09:26 Doubest 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/790/ 题解: 左边部分的下标必定小于右边部分的下标,且左右两边都排好序了,计算即可。 AC代码: #include <iostream> #include <cstring> #include <cstdi 阅读全文
posted @ 2020-02-14 14:27 Doubest 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/description/789/ 题解: 1、找分界点。 2、分别排序 3、归并 递归实现 AC代码: #include <cstdio> #include <cstring> #include <iostre 阅读全文
posted @ 2020-02-14 13:34 Doubest 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1233/ 题解: (飞行时间+时差 + 飞行时间 - 时差) / 2 = 飞行时间 AC代码: #include <cstdio> #include <cstring> #include <iostream> 阅读全文
posted @ 2020-02-13 22:43 Doubest 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1231/ 题解: 估计自己太弱了,处理字符串比较痛苦,最后记得用unique去重。 代码: #include <cstring> #include <cstdio> #include <string> #in 阅读全文
posted @ 2020-02-12 15:54 Doubest 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1221/ 题解: 对于分子分母都是整数的除法,例如a/b,除了可以用ceil()函数向上取整外,还可以直接用公式(a+b-1)/b; 代码: #include <algorithm> #include <io 阅读全文
posted @ 2020-02-12 14:37 Doubest 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1206/ 题解: (1)getline()不会读\n,并且会抛弃读到的\n,而且不会留在缓冲区中。 (2)cin不会读\n,但是会把它留在缓冲区中等其他人读入 (3)stringstream在字符串、数字互转 阅读全文
posted @ 2020-02-11 22:16 Doubest 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://www.acwing.com/problem/content/1216/ 题解: 一定要注意对于负数取余,要用数学上的定义,必须>=0 最后那个s也要记得用函数取余 AC代码: #include <iostream> #include <algorithm> #inclu 阅读全文
posted @ 2020-02-10 16:26 Doubest 阅读(284) 评论(0) 推荐(0) 编辑