摘要: // 区间[l,r]被划分成[l,mid]和[mid+1,r]时使用int baserch_1(int l,int r){ while(l<r) { int mid = l + r>>1; if(check(mid)) r = mid; //check()判断mid是否满足性质 else l = m 阅读全文
posted @ 2023-09-27 19:37 爱努力的人最幸福 阅读(18) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std; const int N = 100010;int n,q[N],temp[N]; void merge_sort(int q[],int l,int r){ if(l>=r) return ; int mid =(l+r) 阅读全文
posted @ 2023-09-27 19:37 爱努力的人最幸福 阅读(17) 评论(0) 推荐(0)
摘要: #include<iostream>using namespace std; const int N = 100010;int n;int q[N];void quick_sort(int q[],int l,int r){ if(l>=r) return ; int i=l-1,j=r+1,x=q 阅读全文
posted @ 2023-09-27 19:36 爱努力的人最幸福 阅读(17) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;const int N = 1e5+10;int h[N],e[N],ne[N],w[N] 阅读全文
posted @ 2021-01-26 17:43 爱努力的人最幸福 阅读(44) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstring>using namespace std;const int N = 510,M = 1e4+10;int n,m,k;int dist[N],backup[N];struct node{ int a,b,w;}edge[M];in 阅读全文
posted @ 2021-01-26 17:30 爱努力的人最幸福 阅读(49) 评论(0) 推荐(0)
摘要: 朴素版dijkstra O(n^2) 用于稠密图 #include<iostream>#include<algorithm>#include<cstring>using namespace std;const int N = 510;int n,m;int g[N][N],dist[N];bool 阅读全文
posted @ 2021-01-26 16:41 爱努力的人最幸福 阅读(59) 评论(0) 推荐(0)
摘要: 代码 #include<iostream>using namespace std; int main(){ int n; cin>>n; int res=1,d2=0,d5=0; for(int i=1;i<=n;i++){ int x=i; while(x%2==0) x/=2,d2++; whi 阅读全文
posted @ 2021-01-26 14:16 爱努力的人最幸福 阅读(126) 评论(0) 推荐(0)
摘要: 比如: string str="abcdefgh"; 如果执行 str.erase(str.begin()+2); 就是把c删除掉了。cout<<str结果为:abdefgh str.erase(str.begin()+i) (i=0,1,2,3,4,5...) +i 就是表示删除第 i+1 位的值 阅读全文
posted @ 2020-11-27 19:27 爱努力的人最幸福 阅读(181) 评论(0) 推荐(0)
摘要: 在主函数下加入一句 ios::sync_with_stdio(false); 在代码中加入这句语句可以提高cin读入数据的速度,使得cin读入数据的能力和scanf相当 int main() { int n; ios::sync_with_stdio(false); cin>>n; .... } 阅读全文
posted @ 2020-11-27 15:56 爱努力的人最幸福 阅读(123) 评论(0) 推荐(0)
摘要: #include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N = 1e5+10,M=1e6+10;int ne[N];int n,m;char p[N],s[ 阅读全文
posted @ 2020-10-27 19:19 爱努力的人最幸福 阅读(77) 评论(0) 推荐(0)