当前位置:网站首页>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';
}
边栏推荐
- 015 C语言基础:C结构体、共用体
- A^2=e | the solution of the equation | what exactly can this equation tell us
- FastDDS的服务器记录-译-
- Common programming abbreviations for orbit attitude
- golang hello 安装环境异常【已解决】
- PostgreSQL basic command tutorial: create a new user admin to access PostgreSQL
- Microservice system design -- microservice monitoring and system resource monitoring design
- 流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
- 012 C语言基础:C数组
- 011 C language basics: C scope rules
猜你喜欢
![[array]bm94 rainwater connection problem - difficult](/img/2b/1934803060d65ea9139ec489a2c5f5.png)
[array]bm94 rainwater connection problem - difficult

QChart笔记2: 添加鼠标悬停显示

快速排序(非递归)和归并排序

Microservice system design -- unified authentication service design

1.5 use of CONDA

为什么 C# 访问 null 字段会抛异常?

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

Almost because of json Stringify lost his bonus

Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?

日志收集系统
随机推荐
微服务系统设计——微服务调用设计
第1章 绪论
MobileNet系列(4):MobileNetv3网络详解
MATLAB | 基于分块图布局的三纵坐标图绘制
007 C语言基础:C运算符
015 C语言基础:C结构体、共用体
真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
015 basics of C language: C structure and common body
020 C语言基础:C语言强制类型转换与错误处理
Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state
022 basics of C language: C memory management and C command line parameters
基于MobileNet-Yolov4搭建轻量化目标检测
PostgreSQL基础命令教程:创建新用户admin来访问PostgreSQL
微服务系统设计——API 网关服务设计
The most detailed download tutorial of MySQL
【B站UP DR_CAN学习笔记】Kalman滤波3
How to make ef core 6 support dateonly type
系统架构设计——互联网金融的架构设计
Kotlin Compose 自定义 CompositionLocalProvider CompositionLocal
Static timing analysis OCV and time derive