题解列表

筛选

归并排序!!!

摘要:```cpp #include using namespace std; const int L = 100000 + 2; int q[L]; int tmp[L]; int n;……

素数判断小小加强写法

摘要:解题思路:1、输入数字小于2直接退出2、大于2直接输出2,为了后面来判断的数字都是基数做个小铺垫,应为偶数不可能是素数嘛3、比较范围上限用根号更好节省时空注意事项:参考代码:#include<iost……

快速排序!!!

摘要:```cpp #include using namespace std; const int L = 100000 + 2; int q[L]; int n; void quick_s……

快速排序!!!!!

摘要:```cpp #include using namespace std; const int L = 10 + 2; int q[L]; int len; void quick_sort(……
优质题解

1102: 明明的随机数

摘要:解题思路:去重:数组的去重是很难直接把重复值“删去”的,此题要求输入的随机数都是正整数,所以可以把重复值全改成0,最后输出非0数,就算去重了。先排序,后去重。排序使用快速排序。注意事项:快速排序函数中……
优质题解

1100: 采药(背包问题)

摘要:解题思路:属于背包问题,用动态规划的思想求解。核心计算公式:t时间内考虑m个草药并且选择“采”的价值,计算公式为:(t - 第m个草药的耗时)时间内考虑(m - 1)个草药的最有解 + 第m个草药的价……

时间换算!!!!

摘要:```cpp #include using namespace std; long long n; int shi, fen, miao; int main(){ cin >> n; ……

1099: 校门外的树

摘要:解题思路:暴力解法,建一个大小为n的数组存储树的状态。时间复杂度是O(n),题解里面那个扫描线差分我还没看懂。注意事项:太暴力太丑陋了。参考代码:// 题目 1099: 校门外的树 #include……