题解列表

筛选

区间中最大的数-题解(C++代码)

直接在区间内找最大值就可以了#includeusingnamespacestd;intfun(inta[],inti,intj){i=i-1,j=j-1;inttemp=0;for(;itemp)temp=a[i];returntemp;}intmain(){intn;cin>>n;//n个数字int

逆序数-题解(C++代码)

其实很简单,将所有数两两进行比较就可以了#includeusingnamespacestd;longlongfun(inta[],intn){longtemp=0;for(inti=0;i

弟弟的作业-题解(C++代码)

摘要:#### 原题链接:[弟弟的作业](https://www.dotcpp.com/oj/problem1073.html "弟弟的作业") #### 解题思路: **能看到这个题目很幸运,……

汽水瓶-题解(C++代码)——简单递归(通俗易懂)

解题思路:本题是很明显的递归思路,实际上就是用两瓶空瓶即可换一瓶饮料喝。因此状态转移方程为f(n-2)+1。参考代码:```cpp#include#includeusingnamespacestd;intf(intn){if(n==0||n==1)return0;if(n==2||n==3)retur

蓝桥杯算法提高VIP-打水问题-题解(C++代码)

先对每个人需要打水的时间进行排序,因为前面打水越快,后面需要等待的时间越短。然后从m+1个人开始,因为有m个水龙头前m个人已经开始打水。第i个人等待的时间是第i-m个人(打水的时间+等待的时间)```cpp#include#include#include#include#include#include

蛇行矩阵-题解(C++代码)

摘要:#### 原题链接:[蛇形矩阵](https://www.dotcpp.com/oj/problem1097.html "蛇形矩阵") #### 解题思路: 1、循环,二维数组 2、蛇形……