当前位置:网站首页>Acwing game 57
Acwing game 57
2022-06-27 13:50:00 【leimingzeOuO】
Catalog
AcWing 4485. Than the size
Ideas :
Enumeration is enough , Grammar questions
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
void solve()
{
cin>>n;
int s1=0,s2=0;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
s1+=x;
}
for(int i=0;i<n;i++)
{
int x;
cin>>x;
s2+=x;
}
if(s1>=s2)puts("Yes");
else puts("No");
}
signed main()
{
io;
//cin>>_;
// while(_--)
solve();
return 0;
}
author :Leimz
link :https://www.acwing.com/activity/content/code/content/3669431/
source :AcWing
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .
AcWing 4486. Digital operation
Ideas :
Think greedily : Multiply only once and divide smoothly is the least operand , So we need to find the number that multiplies .
Yes n n n Do factorization , 5184 = 2 6 ∗ 3 4 5184=2^6*3^4 5184=26∗34
take 6 , 4 6,4 6,4 Make up the smallest one bigger than them 2 2 2 To the power of, that is 8 8 8
So here you are 5184 ∗ 2 2 ∗ 3 4 5184*2^2*3^4 5184∗22∗34, Why 8? Because every time I find the arithmetic square root , amount to finger Count / 2 Index /2 finger Count /2 So I'm looking for 2 To the power of
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
vector<PII>v;
int maxv;
void get_fact()
{
for(int i=2;i<=n/i;i++)
{
if(n%i==0)
{
int s=0;
while(n%i==0)
{
n/=i;
s++;
}
maxv=max(maxv,s);
v.pb({
i,s});
}
}
if(n>1)v.pb({
n,1});
}
void solve()
{
cin>>n;
get_fact();
int s=1;
while(s<maxv)s<<=1;
bool f=false;
for(int i=0;i<v.size();i++)
{
if(v[i].y<s)
{
f=true;
break;
}
}
int res=f;
int m=s;
while(m)
{
res++;
m>>=1;
}
res--;
int ans=1;
for(int i=0;i<v.size();i++)
{
ans*=v[i].x;
}
cout<<ans<<' '<<res<<endl;
}
signed main()
{
io;
// cin>>_;
// while(_--)
solve();
return 0;
}
author :Leimz
link :https://www.acwing.com/activity/content/code/content/3669771/
source :AcWing
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .
AcWing 4487. The longest continuous subsequence
Ideas :
First, analyze the formula 
It is equivalent to finding the average of the longest interval and dividing by 100 Greater than zero
Prefixes and denote S [ r ] − S [ l − 1 ] > 100 ∗ ( l e n ) S[r]-S[l-1]>100*(len) S[r]−S[l−1]>100∗(len)
namely : Preprocessing S [ r ] − 100 ∗ r S[r]-100*r S[r]−100∗r
Enumerate left endpoints , Find the largest right endpoint , If r < l r<l r<l Do not conform to the , Find the longest l e n len len
there m x mx mx Array is the key to binary , Because prefixes and arrays do not necessarily satisfy monotonicity , m x mx mx Arrays are based on the idea of dynamic programming , take r r r The subsequent maximum value is copied to r r r
The same problem can be done with a monotone stack .
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
const int N=1e6+10;
int a[N];
int s[N],mx[N];
void solve()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
for(int i=0;i<=n;i++)s[i]-=100*i;
mx[n+1]=-ll_INF;
for(int i=n;i>=0;i--)mx[i]=max(mx[i+1],s[i]);
int res=0;
for(int i=0;i<n;i++)
{
int l=i+1,r=n;
while(l<r)
{
int mid=l+r+1>>1;
if(mx[mid]>s[i])l=mid;
else r=mid-1;
}
if(mx[l]<=s[i])continue;
res=max(res,l-i);
}
cout<<res<<endl;
}
signed main()
{
io;
// cin>>_;
// while(_--)
solve();
return 0;
}
author :Leimz
link :https://www.acwing.com/activity/content/code/content/3670626/
source :AcWing
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .
边栏推荐
- Firewall foundation Huawei H3C firewall web page login
- crane:字典项与关联数据处理的新思路
- 面试官:Redis的共享对象池了解吗?
- Redis持久化
- Daily 3 questions (1): find the nearest point with the same X or Y coordinate
- JVM performance tuning and monitoring tools -- JPS, jstack, jmap, jhat, jstat, hprof
- Number of printouts (solved by recursive method)
- Why must Oracle cloud customers self test after the release of Oracle cloud quarterly update?
- Crane: a new way of dealing with dictionary items and associated data
- AXI总线
猜你喜欢
![[WUSTCTF2020]girlfriend](/img/a8/33fe5feb7bcbb73ba26a94d226cc4d.png)
[WUSTCTF2020]girlfriend

基于 xml 配置文件的入门级 SSM 框架整合

ENSP cloud configuration
![[XMAN2018排位赛]通行证](/img/eb/7bf04941a96e9522e2b93859266cf2.png)
[XMAN2018排位赛]通行证

【PHP代码注入】PHP语言常见可注入函数以及PHP代码注入漏洞的利用实例

快讯:华为启动鸿蒙开发者大赛;腾讯会议发布“万室如意”计划

清华&商汤&上海AI&CUHK提出Siamese Image Modeling,兼具linear probing和密集预测性能!...

How to set postman to Chinese? (Chinese)

PLM还能怎么用?

IJCAI 2022 | 用一行代码大幅提升零样本学习方法效果,南京理工&牛津提出即插即用分类器模块
随机推荐
Daily question brushing record (6)
OpenHGNN发布0.3版本
[problem solving] which nodes are run in tensorflow?
解析Activity启动-生命周期角度
打印输出数(递归方法解决)
Kotlin函数使用示例教程
实现WordPress上传图片自动重命名的方法
A statistical problem of shell script
Embedded development: embedded foundation callback function
AXI总线
How to solve the problem of missing language bar in win10 system
【业务安全-01】业务安全概述及测试流程
Daily question 3 (2): check binary string field
[XMAN2018排位赛]通行证
PCL库——报错解决:安装时遇到的cmake与anaconda的冲突问题
面试官:Redis的共享对象池了解吗?
NLP - monocleaner
每日3题(1):找到最近的有相同 X 或 Y 坐标的点
[OS command injection] common OS command execution functions and OS command injection utilization examples and range experiments - based on DVWA range
Interviewer: do you understand redis' shared object pool?