#878

复制代码
#include <bits/stdc++.h> #define int long long using namespace std; const int N=1e6+10,mod=1e9+7; string s; int n,t,a[N],f[N],res,num,ans,m; bool vis[N]; signed main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>t; while(t--){ cin>>n; char op; bool f=false; for(int i=0;i<n;i++){ char x; cin>>x; if(f) cout<<x,f=false,op=x; else if(i==0) cout<<x,op=x; else if(x==op) f=true; } cout<<endl; } return 0; }
复制代码

 

复制代码
#include <bits/stdc++.h> #define int long long using namespace std; const int N=1e6+10,mod=1e9+7; string s; int n,t,a[N],f[N],res,num,ans,m; bool vis[N]; signed main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>t; while(t--){ cin>>n>>m; if(m>=30||pow(2,m)>n) cout<<n+1<<endl; else if(n>=pow(2,m)) cout<<(int)pow(2,m)<<endl; } return 0; }
复制代码

 

复制代码
#include <bits/stdc++.h> #define int long long using namespace std; const int N=2e5+10,mod=1e9+7; string s; int n,t,a[N],f[N],res,num,ans,m,k,q; bool vis[N]; signed main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>t; f[1]=1; for(int i=2;i<=N;i++) f[i]=i+f[i-1]; while(t--){ cin>>n>>k>>q; res=0,num=0; for(int i=0;i<n;i++){ cin>>m; if(m<=q) num++; else{ if(num>=k) res+=f[num-k+1]; num=0; } } if(num>=k) res+=f[num-k+1]; cout<<res<<endl; } return 0; }
复制代码

 

//在某一段区间内,一旦最大值减去最小值的差小于等于 x 的二倍,则一定能找到一个值 y
//使最大值最小值分别与 y 相减后的绝对值都不大于x 
复制代码
#include <bits/stdc++.h> #define int long long using namespace std; const int N=1e6+10,mod=1e9+7; string s; int n,t,a[N],f[N],res,num,ans,m; bool vis[N]; bool check(int u) { int i,j,k; for(i=1;i<n;i++) if(a[i]-a[0]>u<<1) break; if(i>=n) return true; for(j=i+1;j<n;j++) if(a[j]-a[i]>u<<1) break; if(j>=n) return true; for(k=j+1;k<n;k++) if(a[k]-a[j]>u<<1) break; if(k>=n) return true; return false; } signed main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>t; while(t--){ cin>>n; for(int i=0;i<n;i++) cin>>a[i]; if(n<3){ cout<<0<<endl; continue; } sort(a,a+n); int l=0,r=a[n-1]; while(l<r){ int mid=l+r>>1; if(check(mid)) r=mid; else l=mid+1; } cout<<r<<endl; } return 0; }
复制代码

 


__EOF__

本文作者Sakurajimamai
本文链接https://www.cnblogs.com/o-Sakurajimamai-o/p/17590910.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   o-Sakurajimamai-o  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
-- --
点击右上角即可分享
微信分享提示