当前位置:网站首页>AcWing 第 57 场周赛---BC题挺好
AcWing 第 57 场周赛---BC题挺好
2022-06-27 04:38:00 【WAWA源】
A. 比大小—签到
#include<iostream>
#include<cstring>
using namespace std;
#define int long long
signed main()
{
int n;cin>>n;
int s1=0,s2=0;
for(int i=0,x;i<n;i++)cin>>x,s1+=x;
for(int i=0,x;i<n;i++)cin>>x,s2+=x;
if(s1>=s2)cout<<"Yes"<<'\n';
else cout<<"No"<<'\n';
}
B.数字操作—算术基本定理
#include<iostream>
#include<cstring>
#include<set>
#include<cmath>
using namespace std;
#define int long long
set<int>S;
signed main()
{
int n;cin>>n;
if(n==1){
cout<<1<<" 0"<<'\n';return 0;}
int res=1,cnt=0;
for(int i=2;i<=n;i++)
{
int s=0;
if(n%i==0)
{
while(n%i==0)n/=i,s++;
res*=i;
S.insert(s);
}
cnt=max(s,cnt);
}
int sum=1,res2=1;
while(sum<cnt)sum*=2,res2++;
if(sum==cnt&&S.size()==1)res2--;
cout<<res<<" "<<res2<<'\n';
}
C. 最长连续子序列—单调栈+贪心+二分
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define int long long
const int N = 1000010;
int a[N],s[N],stk[N];
int top=0;
signed main()
{
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],a[i]-=100;
for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
int res=0;
for(int i=1;i<=n;i++)
{
int l=0,r=top;
while(l<r)
{
int mid=l+r>>1;
if(s[i]-s[stk[mid]]>0)r=mid;
else l=mid+1;
}
if(s[i]<s[stk[top]])stk[++top]=i;
if(s[i]-s[stk[r]]>0)res=max(res,i-stk[r]);
}
cout<<res<<'\n';
}
边栏推荐
- 日志收集系统
- Argo Workflows —— Kubernetes的工作流引擎入门
- 1.5 conda的使用
- How to systematically learn LabVIEW?
- [station B up dr_can learning notes] Kalman filter 3
- 015 C语言基础:C结构体、共用体
- 016 C language foundation: C language enumeration type
- [array]bm94 rainwater connection problem - difficult
- 快速排序(非递归)和归并排序
- List of best reading materials for machine learning in communication
猜你喜欢

math_ Number set (number set symbol) and set theory
![[station B up dr_can learning notes] Kalman filter 3](/img/40/d3ec97be2f29b76a6c049c26ff4998.gif)
[station B up dr_can learning notes] Kalman filter 3
![[unity] button of UI interactive component & summary of optional base classes](/img/9f/be9005f03ad9a2bc8da0f910f064c5.png)
[unity] button of UI interactive component & summary of optional base classes

1.5 use of CONDA

快速掌握 ASP.NET 身份认证框架 Identity - 通过邮件重置密码

渗透测试-文件上传/下载/包含

Installation of low code development platform nocobase

快速排序(非遞歸)和歸並排序

Baidu PaddlePaddle's "universal gravitation" first stop in 2022 landed in Suzhou, comprehensively launching the SME empowerment plan

真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
随机推荐
笔记本电脑没有WiFi选项 解决办法
[数组]BM94 接雨水问题-较难
1.5 use of CONDA
Ledrui ldr6035 usb-c interface device supports rechargeable OTG data transmission scheme.
如何让 EF Core 6 支持 DateOnly 类型
微服务系统设计——服务注册与发现和配置设计
[array]bm94 rainwater connection problem - difficult
MobileNet系列(4):MobileNetv3网络详解
流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
006 C语言基础:C存储类
QChart笔记2: 添加鼠标悬停显示
Microservice system design -- API gateway service design
010 C language foundation: C function
第1章 绪论
Redis高可用集群(哨兵、集群)
013 C语言基础:C指针
018 C语言基础:C文件读写
ES6 0622 III
Système de collecte des journaux
List of best reading materials for machine learning in communication