# luogu-solution **Repository Path**: yicongl1/luogu-solution ## Basic Information - **Project Name**: luogu-solution - **Description**: 洛谷题解存档 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-06 - **Last Updated**: 2026-11-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 洛谷题解归档 2021 年 4 月到 2022 年 4 月期间刷过的洛谷题目,共 **203 道题、204 份代码**(P1706 保留了两份不同实现)。 每份代码文件开头都有一段统一的中文注释,包含题目链接、算法分类、完成时间、题目大意和思路讲解。代码文件按算法类型放入 12 个英文目录,本 README 按同样的顺序索引。 ## 概览 - 题目数量:203 道(204 份代码) - 时间跨度:2021-04-15 ~ 2022-04-04 - 语言分布:C 75 份 / C++ 129 份 - 分类数量:12 类 - 题目链接:`https://www.luogu.com.cn/problem/P1009` - 完成时间取自代码文件的最后修改时间,可能与实际首次 AC 时间略有出入 ## 目录与分类统计 | 目录 | 分类 | 题数 | 占比 | |---|---|---:|---:| | [`basic/`](basic/) | 顺序与分支 | 25 | 12.3% | | [`simulation/`](simulation/) | 循环与模拟 | 56 | 27.5% | | [`enumeration/`](enumeration/) | 枚举 | 24 | 11.8% | | [`sorting/`](sorting/) | 排序 | 17 | 8.3% | | [`string/`](string/) | 字符串处理 | 31 | 15.2% | | [`big-integer/`](big-integer/) | 高精度 | 4 | 2.0% | | [`recursion/`](recursion/) | 递推与递归 | 4 | 2.0% | | [`backtracking/`](backtracking/) | 搜索与回溯 | 1 | 0.5% | | [`greedy/`](greedy/) | 贪心 | 7 | 3.4% | | [`prefix-sum/`](prefix-sum/) | 前缀和与差分 | 3 | 1.5% | | [`math/`](math/) | 数学与数论 | 31 | 15.2% | | [`divide-and-conquer/`](divide-and-conquer/) | 分治 | 1 | 0.5% | | | **合计** | **204** | **100.0%** | ## 月度完成情况 | 月份 | 题数 | |---|---:| | 2021-04 | 27 | | 2021-05 | 77 | | 2021-06 | 27 | | 2021-07 | 9 | | 2021-09 | 24 | | 2021-11 | 25 | | 2022-03 | 7 | | 2022-04 | 8 | ## 题目索引(按算法分类) ### 1. 顺序与分支(25 题,`basic/`) > 按题意顺序执行,配合条件判断完成,属于最基础的入门题。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1055](https://www.luogu.com.cn/problem/P1055) | [NOIP 2008 普及组] ISBN 号码 | 2021-05-04 | [P1055.c](basic/P1055.c) | | [P1085](https://www.luogu.com.cn/problem/P1085) | [NOIP 2004 普及组] 不高兴的津津 | 2021-09-03 | [P1085.cpp](basic/P1085.cpp) | | [P1421](https://www.luogu.com.cn/problem/P1421) | 小玉买文具 | 2021-07-27 | [P1421.cpp](basic/P1421.cpp) | | [P1422](https://www.luogu.com.cn/problem/P1422) | 小玉家的电费 | 2021-09-03 | [P1422.cpp](basic/P1422.cpp) | | [P1425](https://www.luogu.com.cn/problem/P1425) | 小鱼的游泳时间 | 2021-04-16 | [P1425.cpp](basic/P1425.cpp) | | [P1615](https://www.luogu.com.cn/problem/P1615) | 西游记公司 | 2021-05-04 | [P1615.c](basic/P1615.c) | | [P1917](https://www.luogu.com.cn/problem/P1917) | 三子棋II | 2021-09-03 | [P1917.cpp](basic/P1917.cpp) | | [P2433](https://www.luogu.com.cn/problem/P2433) | 【深基1-2】小学数学 N 合一 | 2021-05-06 | [P2433.cpp](basic/P2433.cpp) | | [P3954](https://www.luogu.com.cn/problem/P3954) | [NOIP 2017 普及组] 成绩 | 2021-09-03 | [P3954.cpp](basic/P3954.cpp) | | [P5690](https://www.luogu.com.cn/problem/P5690) | [CSP-S 2019 江西] 日期 | 2021-05-14 | [P5690.cpp](basic/P5690.cpp) | | [P5703](https://www.luogu.com.cn/problem/P5703) | 【深基2.例5】苹果采购 | 2021-04-16 | [P5703.cpp](basic/P5703.cpp) | | [P5706](https://www.luogu.com.cn/problem/P5706) | 【深基2.例8】再分肥宅水 | 2021-04-15 | [P5706.cpp](basic/P5706.cpp) | | [P5709](https://www.luogu.com.cn/problem/P5709) | 【深基2.习6】Apples Prologue / 苹果和虫子 | 2021-07-27 | [P5709.cpp](basic/P5709.cpp) | | [P5710](https://www.luogu.com.cn/problem/P5710) | 【深基3.例2】数的性质 | 2021-05-03 | [P5710.cpp](basic/P5710.cpp) | | [P5711](https://www.luogu.com.cn/problem/P5711) | 【深基3.例3】闰年判断 | 2021-05-03 | [P5711.cpp](basic/P5711.cpp) | | [P5712](https://www.luogu.com.cn/problem/P5712) | 【深基3.例4】Apples | 2021-05-03 | [P5712.cpp](basic/P5712.cpp) | | [P5713](https://www.luogu.com.cn/problem/P5713) | 【深基3.例5】洛谷团队系统 | 2021-05-08 | [P5713.cpp](basic/P5713.cpp) | | [P5740](https://www.luogu.com.cn/problem/P5740) | 【深基7.例9】最厉害的学生 | 2021-11-11 | [P5740.c](basic/P5740.c) | | [P5742](https://www.luogu.com.cn/problem/P5742) | 【深基7.例11】评等级 | 2021-11-11 | [P5742.c](basic/P5742.c) | | [P6382](https://www.luogu.com.cn/problem/P6382) | 『MdOI R2』Car | 2021-05-29 | [P6382.c](basic/P6382.c) | | [P6500](https://www.luogu.com.cn/problem/P6500) | [COCI 2010/2011 #3] ZBROJ | 2021-09-07 | [P6500.cpp](basic/P6500.cpp) | | [P6850](https://www.luogu.com.cn/problem/P6850) | NOI | 2021-09-09 | [P6850.cpp](basic/P6850.cpp) | | [P7257](https://www.luogu.com.cn/problem/P7257) | [COCI 2009/2010 #3] FILIP | 2021-09-09 | [P7257.cpp](basic/P7257.cpp) | | [P7621](https://www.luogu.com.cn/problem/P7621) | [AHOI2021初中组] 超市购物 | 2021-09-07 | [P7621.cpp](basic/P7621.cpp) | | [P8071](https://www.luogu.com.cn/problem/P8071) | [COCI 2009/2010 #7] SPAVANAC | 2022-03-29 | [P8071.c](basic/P8071.c) | ### 2. 循环与模拟(56 题,`simulation/`) > 用循环按题目描述逐步模拟过程,常配合数组、标记和边界判断。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1042](https://www.luogu.com.cn/problem/P1042) | [NOIP 2003 普及组] 乒乓球 | 2021-11-26 | [P1042.cpp](simulation/P1042.cpp) | | [P1046](https://www.luogu.com.cn/problem/P1046) | [NOIP 2005 普及组] 陶陶摘苹果 | 2021-05-27 | [P1046.c](simulation/P1046.c) | | [P1089](https://www.luogu.com.cn/problem/P1089) | [NOIP 2004 提高组] 津津的储蓄计划 | 2021-09-07 | [P1089.cpp](simulation/P1089.cpp) | | [P1152](https://www.luogu.com.cn/problem/P1152) | 欢乐的跳 | 2021-06-15 | [P1152.cpp](simulation/P1152.cpp) | | [P1317](https://www.luogu.com.cn/problem/P1317) | 低洼地 | 2021-05-04 | [P1317.c](simulation/P1317.c) | | [P1319](https://www.luogu.com.cn/problem/P1319) | 压缩技术 | 2021-05-27 | [P1319.c](simulation/P1319.c) | | [P1420](https://www.luogu.com.cn/problem/P1420) | 最长连号 | 2021-05-14 | [P1420.cpp](simulation/P1420.cpp) | | [P1423](https://www.luogu.com.cn/problem/P1423) | 小玉在游泳 | 2021-09-03 | [P1423.cpp](simulation/P1423.cpp) | | [P1424](https://www.luogu.com.cn/problem/P1424) | 小鱼的航程(改进版) | 2021-09-03 | [P1424.cpp](simulation/P1424.cpp) | | [P1426](https://www.luogu.com.cn/problem/P1426) | 小鱼会有危险吗 | 2021-06-15 | [P1426.cpp](simulation/P1426.cpp) | | [P1427](https://www.luogu.com.cn/problem/P1427) | 小鱼的数字游戏 | 2021-05-05 | [P1427.c](simulation/P1427.c) | | [P1534](https://www.luogu.com.cn/problem/P1534) | 不高兴的津津(升级版) | 2021-05-05 | [P1534.c](simulation/P1534.c) | | [P1554](https://www.luogu.com.cn/problem/P1554) | [USACO06DEC] 梦中的统计 Dream Counting B | 2021-05-05 | [P1554.c](simulation/P1554.c) | | [P1567](https://www.luogu.com.cn/problem/P1567) | 统计天数 | 2021-09-05 | [P1567.cpp](simulation/P1567.cpp) | | [P1634](https://www.luogu.com.cn/problem/P1634) | 禽兽的传染病 | 2021-06-15 | [P1634.cpp](simulation/P1634.cpp) | | [P1664](https://www.luogu.com.cn/problem/P1664) | 每日打卡心情好 | 2021-06-15 | [P1664.cpp](simulation/P1664.cpp) | | [P1789](https://www.luogu.com.cn/problem/P1789) | 【Mc生存】插火把 | 2021-04-23 | [P1789.cpp](simulation/P1789.cpp) | | [P1830](https://www.luogu.com.cn/problem/P1830) | 轰炸III | 2021-04-23 | [P1830.cpp](simulation/P1830.cpp) | | [P1867](https://www.luogu.com.cn/problem/P1867) | 【Mc生存】经验值 | 2021-06-15 | [P1867.cpp](simulation/P1867.cpp) | | [P1897](https://www.luogu.com.cn/problem/P1897) | 电梯里的尴尬 | 2021-05-07 | [P1897.cpp](simulation/P1897.cpp) | | [P1909](https://www.luogu.com.cn/problem/P1909) | [NOIP 2016 普及组] 买铅笔 | 2021-09-07 | [P1909.cpp](simulation/P1909.cpp) | | [P1980](https://www.luogu.com.cn/problem/P1980) | [NOIP 2013 普及组] 计数问题 | 2021-09-07 | [P1980.cpp](simulation/P1980.cpp) | | [P2006](https://www.luogu.com.cn/problem/P2006) | 赵神牛的游戏 | 2021-04-17 | [P2006.cpp](simulation/P2006.cpp) | | [P2077](https://www.luogu.com.cn/problem/P2077) | 红绿灯 | 2021-05-28 | [P2077.c](simulation/P2077.c) | | [P2393](https://www.luogu.com.cn/problem/P2393) | yyy loves Maths II | 2021-06-16 | [P2393.cpp](simulation/P2393.cpp) | | [P2669](https://www.luogu.com.cn/problem/P2669) | [NOIP 2015 普及组] 金币 | 2021-05-07 | [P2669.cpp](simulation/P2669.cpp) | | [P2670](https://www.luogu.com.cn/problem/P2670) | [NOIP 2015 普及组] 扫雷游戏 | 2021-09-07 | [P2670.cpp](simulation/P2670.cpp) | | [P2692](https://www.luogu.com.cn/problem/P2692) | 覆盖 | 2021-06-16 | [P2692.cpp](simulation/P2692.cpp) | | [P2956](https://www.luogu.com.cn/problem/P2956) | [USACO09OCT] The Robot Plow G | 2021-04-19 | [P2956.cpp](simulation/P2956.cpp) | | [P3156](https://www.luogu.com.cn/problem/P3156) | 【深基15.例1】询问学号 | 2021-05-09 | [P3156.cpp](simulation/P3156.cpp) | | [P3926](https://www.luogu.com.cn/problem/P3926) | SAC E#1 - 一道不可做题 Jelly | 2021-06-16 | [P3926.cpp](simulation/P3926.cpp) | | [P4439](https://www.luogu.com.cn/problem/P4439) | [COCI 2017/2018 #3] Aron | 2021-05-28 | [P4439.c](simulation/P4439.c) | | [P5594](https://www.luogu.com.cn/problem/P5594) | 【XR-4】模拟赛 | 2021-05-06 | [P5594.c](simulation/P5594.c) | | [P5613](https://www.luogu.com.cn/problem/P5613) | [MtOI2019] 黑蚊子多 | 2021-05-29 | [P5613.c](simulation/P5613.c) | | [P5660](https://www.luogu.com.cn/problem/P5660) | [CSP-J 2019] 数字游戏 | 2021-05-07 | [P5660.cpp](simulation/P5660.cpp) | | [P5718](https://www.luogu.com.cn/problem/P5718) | 【深基4.例2】找最小值 | 2021-04-15 | [P5718.cpp](simulation/P5718.cpp) | | [P5719](https://www.luogu.com.cn/problem/P5719) | 【深基4.例3】分类平均 | 2021-05-08 | [P5719.cpp](simulation/P5719.cpp) | | [P5720](https://www.luogu.com.cn/problem/P5720) | 【深基4.例4】一尺之棰 | 2021-05-08 | [P5720.cpp](simulation/P5720.cpp) | | [P5721](https://www.luogu.com.cn/problem/P5721) | 【深基4.例6】数字直角三角形 | 2021-07-26 | [P5721.cpp](simulation/P5721.cpp) | | [P5722](https://www.luogu.com.cn/problem/P5722) | 【深基4.例11】数列求和 | 2021-05-08 | [P5722.cpp](simulation/P5722.cpp) | | [P5727](https://www.luogu.com.cn/problem/P5727) | 【深基5.例3】冰雹猜想 | 2021-07-27 | [P5727.cpp](simulation/P5727.cpp) | | [P5730](https://www.luogu.com.cn/problem/P5730) | 【深基5.例10】显示屏 | 2021-11-09 | [P5730.c](simulation/P5730.c) | | [P5731](https://www.luogu.com.cn/problem/P5731) | 【深基5.习6】蛇形方阵 | 2021-04-16 | [P5731.cpp](simulation/P5731.cpp) | | [P5737](https://www.luogu.com.cn/problem/P5737) | 【深基7.例3】闰年展示 | 2021-04-16 | [P5737.cpp](simulation/P5737.cpp) | | [P5744](https://www.luogu.com.cn/problem/P5744) | 【深基7.习9】培训 | 2021-05-09 | [P5744.cpp](simulation/P5744.cpp) | | [P5886](https://www.luogu.com.cn/problem/P5886) | Hello, 2020! | 2021-04-17 | [P5886.cpp](simulation/P5886.cpp) | | [P6056](https://www.luogu.com.cn/problem/P6056) | [加油武汉] SIR 模型 | 2021-05-03 | [P6056.cpp](simulation/P6056.cpp) | | [P6194](https://www.luogu.com.cn/problem/P6194) | [EER1] 苏联人 | 2021-05-14 | [P6194.cpp](simulation/P6194.cpp) | | [P6206](https://www.luogu.com.cn/problem/P6206) | [USACO06OCT] Another Cow Number Game G | 2021-04-19 | [P6206.cpp](simulation/P6206.cpp) | | [P6321](https://www.luogu.com.cn/problem/P6321) | [COCI 2006/2007 #4] SKENER | 2021-04-19 | [P6321.cpp](simulation/P6321.cpp) | | [P6336](https://www.luogu.com.cn/problem/P6336) | [COCI 2007/2008 #2] BIJELE | 2021-09-09 | [P6336.cpp](simulation/P6336.cpp) | | [P6367](https://www.luogu.com.cn/problem/P6367) | [COCI 2006/2007 #6] PRASE | 2021-05-14 | [P6367.cpp](simulation/P6367.cpp) | | [P6461](https://www.luogu.com.cn/problem/P6461) | [COCI 2006/2007 #5] TRIK | 2022-04-04 | [P6461.c](simulation/P6461.c) | | [P6866](https://www.luogu.com.cn/problem/P6866) | [COCI 2019/2020 #5] Emacs | 2021-05-14 | [P6866.cpp](simulation/P6866.cpp) | | [P7748](https://www.luogu.com.cn/problem/P7748) | [COCI 2013/2014 #2] VOLIM | 2022-04-04 | [P7748.c](simulation/P7748.c) | | [P7754](https://www.luogu.com.cn/problem/P7754) | [COCI 2012/2013 #3] SAHOVNICA | 2022-04-04 | [P7754.c](simulation/P7754.c) | ### 3. 枚举(24 题,`enumeration/`) > 在有限范围内穷举所有可能,再逐一验证。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1047](https://www.luogu.com.cn/problem/P1047) | [NOIP 2005 普及组] 校门外的树 | 2021-06-14 | [P1047.cpp](enumeration/P1047.cpp) | | [P1151](https://www.luogu.com.cn/problem/P1151) | 子数整数 | 2021-06-15 | [P1151.cpp](enumeration/P1151.cpp) | | [P1179](https://www.luogu.com.cn/problem/P1179) | [NOIP 2010 普及组] 数字统计 | 2021-05-29 | [P1179.c](enumeration/P1179.c) | | [P1205](https://www.luogu.com.cn/problem/P1205) | [USACO1.2] 方块转换 Transformations | 2021-11-10 | [P1205.c](enumeration/P1205.c) | | [P1428](https://www.luogu.com.cn/problem/P1428) | 小鱼比可爱 | 2021-06-15 | [P1428.cpp](enumeration/P1428.cpp) | | [P1548](https://www.luogu.com.cn/problem/P1548) | [NOIP 1997 普及组] 棋盘问题 | 2021-05-14 | [P1548.cpp](enumeration/P1548.cpp) | | [P1590](https://www.luogu.com.cn/problem/P1590) | 失踪的7 | 2021-05-15 | [P1590.cpp](enumeration/P1590.cpp) | | [P1706](https://www.luogu.com.cn/problem/P1706) | 全排列问题(暴力枚举版) | 2021-04-19 | [P1706.cpp](enumeration/P1706.cpp) | | [P1838](https://www.luogu.com.cn/problem/P1838) | 三子棋I | 2021-05-08 | [P1838/main.cpp](enumeration/P1838/main.cpp) | | [P1927](https://www.luogu.com.cn/problem/P1927) | 防护伞 | 2021-07-27 | [P1927.cpp](enumeration/P1927.cpp) | | [P2074](https://www.luogu.com.cn/problem/P2074) | 危险区域 | 2021-06-18 | [P2074.cpp](enumeration/P2074.cpp) | | [P2141](https://www.luogu.com.cn/problem/P2141) | [NOIP 2014 普及组] 珠心算测验 | 2021-06-16 | [P2141.cpp](enumeration/P2141.cpp) | | [P2356](https://www.luogu.com.cn/problem/P2356) | 弹珠游戏 | 2021-05-27 | [P2356.c](enumeration/P2356.c) | | [P2524](https://www.luogu.com.cn/problem/P2524) | Uim的情人节礼物·其之弐 | 2021-04-24 | [P2524.cpp](enumeration/P2524.cpp) | | [P2550](https://www.luogu.com.cn/problem/P2550) | [AHOI2001] 彩票摇奖 | 2021-05-28 | [P2550.c](enumeration/P2550.c) | | [P2666](https://www.luogu.com.cn/problem/P2666) | [USACO07OCT] Bessie's Secret Pasture S | 2021-06-14 | [P2666.cpp](enumeration/P2666.cpp) | | [P2911](https://www.luogu.com.cn/problem/P2911) | [USACO08OCT] Bovine Bones G | 2021-06-18 | [P2911.cpp](enumeration/P2911.cpp) | | [P3717](https://www.luogu.com.cn/problem/P3717) | [AHOI2017初中组] cover | 2021-04-18 | [P3717.cpp](enumeration/P3717.cpp) | | [P4956](https://www.luogu.com.cn/problem/P4956) | [COCI 2017/2018 #6] Davor | 2021-05-08 | [P4956.cpp](enumeration/P4956.cpp) | | [P5728](https://www.luogu.com.cn/problem/P5728) | 【深基5.例5】旗鼓相当的对手 | 2021-05-03 | [P5728.cpp](enumeration/P5728.cpp) | | [P5741](https://www.luogu.com.cn/problem/P5741) | 【深基7.例10】旗鼓相当的对手 - 加强版 | 2021-11-11 | [P5741.c](enumeration/P5741.c) | | [P5831](https://www.luogu.com.cn/problem/P5831) | [USACO19DEC] Cow Gymnastics B | 2021-05-06 | [P5831.c](enumeration/P5831.c) | | [P6685](https://www.luogu.com.cn/problem/P6685) | 可持久化动态仙人掌的直径问题 | 2022-03-30 | [P6685.c](enumeration/P6685.c) | | [P6723](https://www.luogu.com.cn/problem/P6723) | [COCI 2015/2016 #5] ZAMKA | 2022-03-30 | [P6723.c](enumeration/P6723.c) | ### 4. 排序(17 题,`sorting/`) > 按关键字排序(内置排序或手写快排、选择排序)后再统计或输出。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1012](https://www.luogu.com.cn/problem/P1012) | [NOIP 1998 提高组] 拼数 | 2021-11-16 | [P1012.c](sorting/P1012.c) | | [P1059](https://www.luogu.com.cn/problem/P1059) | [NOIP 2006 普及组] 明明的随机数 | 2021-05-07 | [P1059.cpp](sorting/P1059.cpp) | | [P1068](https://www.luogu.com.cn/problem/P1068) | [NOIP 2009 普及组] 分数线划定 | 2021-11-15 | [P1068.c](sorting/P1068.c) | | [P1093](https://www.luogu.com.cn/problem/P1093) | [NOIP 2007 普及组] 奖学金 | 2021-11-15 | [P1093.c](sorting/P1093.c) | | [P1104](https://www.luogu.com.cn/problem/P1104) | 生日 | 2021-11-16 | [P1104.c](sorting/P1104.c) | | [P1116](https://www.luogu.com.cn/problem/P1116) | 车厢重组 | 2021-04-17 | [P1116.cpp](sorting/P1116.cpp) | | [P1177](https://www.luogu.com.cn/problem/P1177) | 【模板】排序 | 2021-11-13 | [P1177.c](sorting/P1177.c) | | [P1271](https://www.luogu.com.cn/problem/P1271) | 【深基9.例1】选举学生会 | 2021-11-13 | [P1271.c](sorting/P1271.c) | | [P1296](https://www.luogu.com.cn/problem/P1296) | 奶牛的耳语 | 2021-05-27 | [P1296.c](sorting/P1296.c) | | [P1603](https://www.luogu.com.cn/problem/P1603) | 斯诺登的密码 | 2021-11-10 | [P1603.c](sorting/P1603.c) | | [P2637](https://www.luogu.com.cn/problem/P2637) | [USACO08NOV] 第一次,第二次,成交!Going Once, Going Twice, Gone! B | 2021-06-18 | [P2637.cpp](sorting/P2637.cpp) | | [P2676](https://www.luogu.com.cn/problem/P2676) | [USACO07DEC] Bookshelf B | 2021-05-01 | [P2676.cpp](sorting/P2676.cpp) | | [P4414](https://www.luogu.com.cn/problem/P4414) | [COCI 2006/2007 #2] ABC | 2021-05-29 | [P4414.c](sorting/P4414.c) | | [P4613](https://www.luogu.com.cn/problem/P4613) | [COCI 2017/2018 #5] Olivander | 2021-05-29 | [P4613.c](sorting/P4613.c) | | [P5143](https://www.luogu.com.cn/problem/P5143) | 攀爬者 | 2021-11-11 | [P5143.c](sorting/P5143.c) | | [P5715](https://www.luogu.com.cn/problem/P5715) | 【深基3.例8】三位数排序 | 2021-05-03 | [P5715.cpp](sorting/P5715.cpp) | | [P5738](https://www.luogu.com.cn/problem/P5738) | 【深基7.例4】歌唱比赛 | 2021-11-11 | [P5738.c](sorting/P5738.c) | ### 5. 字符串处理(31 题,`string/`) > 围绕字符扫描、子串、大小写、分词和格式转换。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1125](https://www.luogu.com.cn/problem/P1125) | [NOIP 2008 提高组] 笨小猴 | 2021-11-10 | [P1125.c](string/P1125.c) | | [P1200](https://www.luogu.com.cn/problem/P1200) | [USACO1.1] 你的飞碟在这儿 Your Ride Is Here | 2021-05-04 | [P1200.c](string/P1200.c) | | [P1307](https://www.luogu.com.cn/problem/P1307) | [NOIP 2011 普及组] 数字反转 | 2021-09-07 | [P1307.cpp](string/P1307.cpp) | | [P1308](https://www.luogu.com.cn/problem/P1308) | [NOIP 2011 普及组] 统计单词数 | 2021-11-10 | [P1308.c](string/P1308.c) | | [P1320](https://www.luogu.com.cn/problem/P1320) | 压缩技术(续集版) | 2021-06-14 | [P1320.cpp](string/P1320.cpp) | | [P1321](https://www.luogu.com.cn/problem/P1321) | 单词覆盖还原 | 2021-05-14 | [P1321.cpp](string/P1321.cpp) | | [P1553](https://www.luogu.com.cn/problem/P1553) | 数字反转(升级版) | 2021-11-10 | [P1553.c](string/P1553.c) | | [P1597](https://www.luogu.com.cn/problem/P1597) | 语句解析 | 2021-05-27 | [P1597.c](string/P1597.c) | | [P1598](https://www.luogu.com.cn/problem/P1598) | [USACO03FEB] 垂直柱状图 Vertical Histogram | 2021-07-26 | [P1598.cpp](string/P1598.cpp) | | [P1739](https://www.luogu.com.cn/problem/P1739) | 表达式括号匹配 | 2021-05-04 | [P1739.c](string/P1739.c) | | [P1765](https://www.luogu.com.cn/problem/P1765) | 手机 | 2021-05-27 | [P1765.c](string/P1765.c) | | [P1781](https://www.luogu.com.cn/problem/P1781) | 宇宙总统 | 2021-11-13 | [P1781.c](string/P1781.c) | | [P1914](https://www.luogu.com.cn/problem/P1914) | 小书童——凯撒密码 | 2021-09-07 | [P1914.cpp](string/P1914.cpp) | | [P1957](https://www.luogu.com.cn/problem/P1957) | 口算练习题 | 2021-11-10 | [P1957.c](string/P1957.c) | | [P2084](https://www.luogu.com.cn/problem/P2084) | 进制转换 | 2021-04-17 | [P2084.cpp](string/P2084.cpp) | | [P2548](https://www.luogu.com.cn/problem/P2548) | [AHOI2004] 智能探险车 | 2021-06-18 | [P2548.cpp](string/P2548.cpp) | | [P2708](https://www.luogu.com.cn/problem/P2708) | 硬币翻转 | 2021-05-15 | [P2708.cpp](string/P2708.cpp) | | [P2788](https://www.luogu.com.cn/problem/P2788) | 数学1(math1)- 加减算式 | 2021-05-10 | [P2788.cpp](string/P2788.cpp) | | [P2955](https://www.luogu.com.cn/problem/P2955) | [USACO09OCT] Even? Odd? G | 2021-05-06 | [P2955.c](string/P2955.c) | | [P3741](https://www.luogu.com.cn/problem/P3741) | 小果的键盘 | 2021-05-29 | [P3741.c](string/P3741.c) | | [P3742](https://www.luogu.com.cn/problem/P3742) | umi的函数 | 2021-04-18 | [P3742.cpp](string/P3742.cpp) | | [P4327](https://www.luogu.com.cn/problem/P4327) | [COCI 2006/2007 #1] Okviri | 2021-04-17 | [P4327.cpp](string/P4327.cpp) | | [P5015](https://www.luogu.com.cn/problem/P5015) | [NOIP 2018 普及组] 标题统计 | 2021-09-05 | [P5015.cpp](string/P5015.cpp) | | [P5601](https://www.luogu.com.cn/problem/P5601) | 小 D 与笔试 | 2021-06-05 | [P5601.c](string/P5601.c) | | [P5705](https://www.luogu.com.cn/problem/P5705) | 【深基2.例7】数字反转 | 2021-04-16 | [P5705.cpp](string/P5705.cpp) | | [P5734](https://www.luogu.com.cn/problem/P5734) | 【深基6.例6】文字处理软件 | 2021-04-16 | [P5734.cpp](string/P5734.cpp) | | [P5832](https://www.luogu.com.cn/problem/P5832) | [USACO19DEC] Where Am I? B | 2021-06-08 | [P5832.cpp](string/P5832.cpp) | | [P6263](https://www.luogu.com.cn/problem/P6263) | [COCI 2014/2015 #3] STROJOPIS | 2021-05-14 | [P6263.cpp](string/P6263.cpp) | | [P6832](https://www.luogu.com.cn/problem/P6832) | [Cnoi2020] 子弦 | 2022-04-03 | [P6832.c](string/P6832.c) | | [P6882](https://www.luogu.com.cn/problem/P6882) | [COCI 2016/2017 #3] Imena | 2022-04-03 | [P6882.c](string/P6882.c) | | [P7001](https://www.luogu.com.cn/problem/P7001) | [NEERC 2013] Fraud Busters | 2021-09-07 | [P7001.cpp](string/P7001.cpp) | ### 6. 高精度(4 题,`big-integer/`) > 用数组按位存储,手写竖式加、减、乘、除。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1009](https://www.luogu.com.cn/problem/P1009) | [NOIP 1998 普及组] 阶乘之和 | 2021-11-28 | [P1009.c](big-integer/P1009.c) | | [P1303](https://www.luogu.com.cn/problem/P1303) | A*B Problem | 2021-11-28 | [P1303.c](big-integer/P1303.c) | | [P1601](https://www.luogu.com.cn/problem/P1601) | 高精度加法 | 2021-11-26 | [P1601.c](big-integer/P1601.c) | | [P2394](https://www.luogu.com.cn/problem/P2394) | yyy loves Chemistry I | 2021-05-15 | [P2394.cpp](big-integer/P2394.cpp) | ### 7. 递推与递归(4 题,`recursion/`) > 由边界推出后续状态,或把问题递归分解成同类子问题。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1720](https://www.luogu.com.cn/problem/P1720) | 月落乌啼算钱(斐波那契数列) | 2021-05-14 | [P1720.cpp](recursion/P1720.cpp) | | [P5461](https://www.luogu.com.cn/problem/P5461) | 赦免战俘 | 2021-11-11 | [P5461.c](recursion/P5461.c) | | [P5732](https://www.luogu.com.cn/problem/P5732) | 【深基5.习7】杨辉三角 | 2021-05-09 | [P5732.cpp](recursion/P5732.cpp) | | [P5743](https://www.luogu.com.cn/problem/P5743) | 【深基7.习8】猴子吃桃 | 2021-04-16 | [P5743.cpp](recursion/P5743.cpp) | ### 8. 搜索与回溯(1 题,`backtracking/`) > DFS 枚举状态空间,回溯时撤销选择。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1706](https://www.luogu.com.cn/problem/P1706) | 全排列问题(DFS 回溯版) | 2021-04-20 | [P1706-plus.cpp](backtracking/P1706-plus.cpp) | ### 9. 贪心(7 题,`greedy/`) > 每步取局部最优,并依赖题目性质保证全局最优。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P2525](https://www.luogu.com.cn/problem/P2525) | Uim的情人节礼物·其之壱 | 2021-04-24 | [P2525.cpp](greedy/P2525.cpp) | | [P2689](https://www.luogu.com.cn/problem/P2689) | 东南西北 | 2021-06-08 | [P2689.cpp](greedy/P2689.cpp) | | [P4445](https://www.luogu.com.cn/problem/P4445) | [AHOI2018初中组] 报名签到 | 2021-05-06 | [P4445.c](greedy/P4445.c) | | [P6443](https://www.luogu.com.cn/problem/P6443) | [COCI 2010/2011 #1] TIMSKO | 2021-05-07 | [P6443.c](greedy/P6443.c) | | [P7174](https://www.luogu.com.cn/problem/P7174) | [COCI 2014/2015 #4] CESTA | 2022-04-03 | [P7174.c](greedy/P7174.c) | | [P7285](https://www.luogu.com.cn/problem/P7285) | 「EZEC-5」修改数组 | 2021-09-09 | [P7285.cpp](greedy/P7285.cpp) | | [P7625](https://www.luogu.com.cn/problem/P7625) | [COCI 2011/2012 #1] JABUKE | 2022-04-04 | [P7625.c](greedy/P7625.c) | ### 10. 前缀和与差分(3 题,`prefix-sum/`) > 预处理前缀和或差分,把区间查询、区间修改降为 O(1)。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1568](https://www.luogu.com.cn/problem/P1568) | 赛跑 | 2021-05-05 | [P1568.c](prefix-sum/P1568.c) | | [P1614](https://www.luogu.com.cn/problem/P1614) | 爱与愁的心痛 | 2021-06-15 | [P1614.cpp](prefix-sum/P1614.cpp) | | [P5638](https://www.luogu.com.cn/problem/P5638) | 【CSGRound2】光骓者的荣耀 | 2021-05-06 | [P5638.c](prefix-sum/P5638.c) | ### 11. 数学与数论(31 题,`math/`) > 公式推导、质数、约数、进制、组合计数与几何计算。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1075](https://www.luogu.com.cn/problem/P1075) | [NOIP 2012 普及组] 质因数分解 | 2021-06-14 | [P1075.cpp](math/P1075.cpp) | | [P1146](https://www.luogu.com.cn/problem/P1146) | 硬币翻转 | 2021-05-03 | [P1146.c](math/P1146.c) | | [P1482](https://www.luogu.com.cn/problem/P1482) | Cantor表(升级版) | 2021-05-05 | [P1482.c](math/P1482.c) | | [P1579](https://www.luogu.com.cn/problem/P1579) | 哥德巴赫猜想(升级版) | 2021-06-16 | [P1579.cpp](math/P1579.cpp) | | [P1652](https://www.luogu.com.cn/problem/P1652) | 圆 | 2021-06-15 | [P1652.cpp](math/P1652.cpp) | | [P1851](https://www.luogu.com.cn/problem/P1851) | 好朋友 | 2021-07-27 | [P1851.cpp](math/P1851.cpp) | | [P1876](https://www.luogu.com.cn/problem/P1876) | 开灯 | 2021-05-09 | [P1876.cpp](math/P1876.cpp) | | [P1887](https://www.luogu.com.cn/problem/P1887) | 乘积最大3 | 2021-06-15 | [P1887.cpp](math/P1887.cpp) | | [P1888](https://www.luogu.com.cn/problem/P1888) | 三角函数 | 2021-05-09 | [P1888.cpp](math/P1888.cpp) | | [P2043](https://www.luogu.com.cn/problem/P2043) | 质因子分解 | 2021-05-04 | [P2043.c](math/P2043.c) | | [P2181](https://www.luogu.com.cn/problem/P2181) | 对角线 | 2021-04-17 | [P2181.cpp](math/P2181.cpp) | | [P2192](https://www.luogu.com.cn/problem/P2192) | HXY玩卡片 | 2021-05-27 | [P2192.c](math/P2192.c) | | [P3150](https://www.luogu.com.cn/problem/P3150) | pb的游戏(1) | 2021-04-17 | [P3150.cpp](math/P3150.cpp) | | [P4326](https://www.luogu.com.cn/problem/P4326) | [COCI 2006/2007 #1] Herman | 2021-05-03 | [P4326.cpp](math/P4326.cpp) | | [P4413](https://www.luogu.com.cn/problem/P4413) | [COCI 2006/2007 #2] R2 | 2021-05-14 | [P4413.cpp](math/P4413.cpp) | | [P4702](https://www.luogu.com.cn/problem/P4702) | 取石子 | 2021-06-18 | [P4702.cpp](math/P4702.cpp) | | [P5082](https://www.luogu.com.cn/problem/P5082) | 成绩 | 2021-05-14 | [P5082.cpp](math/P5082.cpp) | | [P5534](https://www.luogu.com.cn/problem/P5534) | 【XR-3】等差数列 | 2021-05-07 | [P5534.cpp](math/P5534.cpp) | | [P5708](https://www.luogu.com.cn/problem/P5708) | 【深基2.习2】三角形面积 | 2021-05-03 | [P5708.cpp](math/P5708.cpp) | | [P5735](https://www.luogu.com.cn/problem/P5735) | 【深基7.例1】距离函数 | 2021-07-27 | [P5735.cpp](math/P5735.cpp) | | [P6159](https://www.luogu.com.cn/problem/P6159) | [Cnoi2020] 光图 | 2021-05-06 | [P6159.c](math/P6159.c) | | [P6284](https://www.luogu.com.cn/problem/P6284) | [COCI 2016/2017 #1] Tarifa | 2022-04-03 | [P6284.c](math/P6284.c) | | [P6320](https://www.luogu.com.cn/problem/P6320) | [COCI 2006/2007 #4] SIBICE | 2021-07-27 | [P6320.cpp](math/P6320.cpp) | | [P6386](https://www.luogu.com.cn/problem/P6386) | [COCI 2007/2008 #4] VAUVAU | 2021-05-06 | [P6386.cpp](math/P6386.cpp) | | [P6426](https://www.luogu.com.cn/problem/P6426) | [COCI 2008/2009 #1] SKOCIMIS | 2021-09-09 | [P6426.cpp](math/P6426.cpp) | | [P7578](https://www.luogu.com.cn/problem/P7578) | 「RdOI R2」数(number) | 2021-09-07 | [P7578.cpp](math/P7578.cpp) | | [P7695](https://www.luogu.com.cn/problem/P7695) | [COCI 2009/2010 #4] PLANINA | 2021-09-09 | [P7695.cpp](math/P7695.cpp) | | [P7901](https://www.luogu.com.cn/problem/P7901) | 「PMOI-0」一笔画 | 2022-03-29 | [P7901.c](math/P7901.c) | | [P8012](https://www.luogu.com.cn/problem/P8012) | [COCI 2013/2014 #4] NASLJEDSTVO | 2022-03-29 | [P8012.c](math/P8012.c) | | [P8072](https://www.luogu.com.cn/problem/P8072) | [COCI 2009/2010 #7] COKOLADA | 2022-03-29 | [P8072.c](math/P8072.c) | | [P8225](https://www.luogu.com.cn/problem/P8225) | 「Wdoi-5」天才⑨与天才拆分 | 2022-03-29 | [P8225.c](math/P8225.c) | ### 12. 分治(1 题,`divide-and-conquer/`) > 把问题拆成规模更小的同类子问题,分别求解后合并。 | 题号 | 题目 | 完成时间 | 代码 | |---|---|---|---| | [P1923](https://www.luogu.com.cn/problem/P1923) | 【深基9.例4】求第 k 小的数 | 2021-11-13 | [P1923.c](divide-and-conquer/P1923.c) | ## 其他练习 `misc/practice/` 下保留了 5 个非题号的个人练习,同样补充了注释头,但不计入上面的题目统计。 | 练习 | 内容 | 分类 | 完成时间 | 代码 | |---|---|---|---|---| | BMI | 计算 BMI 并按阈值给出评价和建议体重范围 | 顺序与分支 | 2021-06-08 | [bmi/main.cpp](misc/practice/bmi/main.cpp) | | 快速排序 | 快排、挖坑快排与选择排序的实现和对拍 | 排序 | 2021-11-25 | [quicksort/main.cpp](misc/practice/quicksort/main.cpp) | | 字符串读入 | 成对读入字符串并按奇偶位置分行输出 | 字符串处理 | 2021-11-17 | [stringsort/main.cpp](misc/practice/stringsort/main.cpp) | | 阶乘打表 | 用 switch 输出 1! 到 12! | 顺序与分支 | 2021-04-15 | [阶乘/main.cpp](misc/practice/阶乘/main.cpp) | | 高精度 | 大整数加法与乘法的竖式实现 | 高精度 | 2021-11-26 | [高精度/main.c](misc/practice/高精度/main.c) | ## 文件说明 - 单文件题:直接放在对应分类目录下,例如 `simulation/P1009.c`、`sorting/P1012.cpp`。 - 多文件题:保留同名子目录,例如 `enumeration/P1838/main.cpp`;该目录中的 `play_fool.*` 是无关的实验代码,已在文件头注明。 - `enumeration/P1706.cpp` 是暴力枚举实现,`backtracking/P1706-plus.cpp` 是 DFS 回溯实现,两文件共用同一题面。 - 除新补充的文件头注释外,原有代码主体保持原样,未做统一重写。 - 题目大意根据归档时的洛谷题面概括,若题目后续更新,描述可能有细微出入。 - 目录与算法的对应关系见上方“目录与分类统计”表。 --- > 我还记得我们一起刷洛谷的时光,在一鸣用你那个好重的电脑。我们一起学习、比谁的代码更优化。不知道你在哪里了,也许我们的爱情枯萎了,但祝愿你一切都好