04 2022 档案
摘要:#include<bits/stdc++.h> using namespace std; bool cmp(vector<int> &A,vector<int> &B){ if(A.size()!=B.size())return A.size()>B.size(); for(int i=A.size
阅读全文
摘要:给定一个长度为 nn 的整数序列,请找出最长的不包含重复的数的连续区间,输出它的长度。 输入格式 第一行包含整数 nn。 第二行包含 nn 个整数(均在 0∼1050∼105 范围内),表示整数序列。 输出格式 共一行,包含一个整数,表示最长的不包含重复的数的连续区间的长度。 数据范围 1≤n≤10
阅读全文
摘要:#include<iostream> #include<vector> using namespace std; vector<int> add(vector<int> &a, vector<int> &b){ if(a.size()<b.size()) return add(b, a); vect
阅读全文
摘要:求 1+2+...+n ,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 英雄哥递归专题直播。 如果 && 前的语句为假,则其之后的也不会执行。 class Solution { public: int sumNums(int n
阅读全文
摘要:这道题着重注意边界问题。 二分题目思路与两种模板的使用。 区分左和右分界点。 二分查找的实质是分治。 1,递归实现子问题,通过while循环来实现。 2,合并子问题,对二分查找来说不需要这一步。 适用于寻找右边部分的分界点,即右分界点。 举例来说,对于排好序数组 {1 2 3 4 5 6}。 对于二
阅读全文
摘要:#include<iostream> using namespace std; const int N = 1e6+10; int n; long long cnt=0; int q[N],tmp[N]; void count(int q[],int l,int r) { if(l>=r)retur
阅读全文
摘要:代码模板 #include<iostream> using namespace std; const int N = 1e6+10; int a[N]; void quicksort(int a[],int l,int r) { if(l>=r) return ; int x = a[l],i=l-
阅读全文
摘要:代码模板 #include<iostream> using namespace std; const int N = 1e6 + 10; int n; int q[N],tmp[N]; void mergesort(int q[],int l,int r){ if(l>=r)return ; int
阅读全文
摘要:代码模板: #include<iostream> using namespace std; const int N = 1e6+10; int a[N]; void quicksort(int a[],int l,int r){ if(l>=r)return ; int x=a[l],i=l-1,j
阅读全文