当前位置:网站首页>Acwing's 57th weekly match -- BC question is very good
Acwing's 57th weekly match -- BC question is very good
2022-06-27 05:03:00 【Wawa source】
A. Than the size — Sign in
#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. Digital operation — Basic theorem of arithmetic
#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. The longest continuous subsequence — Monotonic stack + greedy + Two points
#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';
}
边栏推荐
- Matlab | visualization of mathematical properties related to three interesting circles
- 笔记本电脑没有WiFi选项 解决办法
- 018 C语言基础:C文件读写
- unity点光源消失
- 牛客练习赛101-C 推理小丑---位运算+思维
- stm32读取IO高低电平状态
- jq怎么获取元素的id名
- Interview: what are the positioning methods in selenium? Which one do you use most?
- Microservice system design -- distributed cache service design
- 008 C language foundation: C judgment
猜你喜欢

Microservice system design -- message caching service design

机械转码日记【17】模板,STL简介

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

Edge在IE模式下加载网页 - Edge设置IE兼容性

Microservice system design -- Distributed timing service design

Kotlin compose compositionlocalof and staticcompositionlocalof

微服务系统设计——服务注册与发现和配置设计

What is BFC? What's the usage?

STM32 reads IO high and low level status

清华大学开源软件镜像站网址
随机推荐
011 C language basics: C scope rules
[array]bm94 rainwater connection problem - difficult
体验 win10 下 oceanbase 数据库
渗透测试-文件上传/下载/包含
[unity] button of UI interactive component & summary of optional base classes
齐纳二极管 稳压二极管 SOD123封装 正负区分
jq怎么获取元素的id名
three.js第一人称 相机前枪的跟随
微服务系统设计——分布式定时服务设计
math_ Number set (number set symbol) and set theory
Deep dive kotlin synergy (XV): Test kotlin synergy
020 basics of C language: C language forced type conversion and error handling
MySql最详细的下载教程
论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
022 basics of C language: C memory management and C command line parameters
py2neo基本语法
Microservice system design -- distributed lock service design
STM32 reads IO high and low level status
【622. 设计循环队列】
Cultural tourism night tour | stimulate tourists' enthusiasm with immersive visual experience