当前位置:网站首页>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';
}
边栏推荐
猜你喜欢

Microservice system design -- API gateway service design
![[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
![[BJDCTF2020]The mystery of ip](/img/f8/c3a7334252724635d42c8db3d1bbb0.png)
[BJDCTF2020]The mystery of ip

低代码开发平台NocoBase的安装

【C语言】关键字的补充

1.5 conda的使用

【B站UP DR_CAN学习笔记】Kalman滤波2

微服务系统设计——分布式定时服务设计

真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
![[station B up dr_can learning notes] Kalman filter 2](/img/52/777f2ad2db786c38fd9cd3fe55142c.gif)
[station B up dr_can learning notes] Kalman filter 2
随机推荐
015 basics of C language: C structure and common body
Laptop does not have WiFi option solution
DAST 黑盒漏洞扫描器 第六篇:运营篇(终)
Common programming abbreviations for orbit attitude
A^2=e | the solution of the equation | what exactly can this equation tell us
2022-06-26:以下golang代码输出什么?A:true;B:false;C:编译错误。 package main import “fmt“ func main() { type
Network structure and model principle of convolutional neural network (CNN)
021 basics of C language: recursion, variable parameters
Fplan powerplan instance
015 C语言基础:C结构体、共用体
真xx相来了?测试/开发程序员为什么不愿意加班,这是个疯狂的状态......
020 basics of C language: C language forced type conversion and error handling
Fplan power planning
ES6 0622 III
022 basics of C language: C memory management and C command line parameters
Penetration test - file upload / download / include
Mobilenet series (4): mobilenetv3 network details
Cultural tourism night tour | stimulate tourists' enthusiasm with immersive visual experience
Mysql database foundation: DQL data query language
1.5 conda的使用