当前位置:网站首页>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 .
边栏推荐
- IJCAI 2022 | greatly improve the effect of zero sample learning method with one line of code. Nanjing Institute of Technology & Oxford proposed the plug and play classifier module
- [day 27] given an integer n, print out the full permutation from 1 to n | Full Permutation template
- Pytorch learning 3 (test training model)
- PCL库——报错解决:安装时遇到的cmake与anaconda的冲突问题
- [安洵杯 2019]Attack
- 对半查找(折半查找)
- Openssf security plan: SBOM will drive software supply chain security
- my.ini文件配置
- 为什么 Oracle 云客户必须在Oracle Cloud 季度更新发布后自行测试?
- Why must Oracle cloud customers self test after the release of Oracle cloud quarterly update?
猜你喜欢

The second part of the travel notes of C (Part II) structural thinking: Zen is stable; all four advocate structure

Redis持久化

Axi bus

Implementing springboard agent through SSH port forwarding configuration

AXI總線

CMOS level circuit analysis

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

高效率取幂运算

《预训练周刊》第51期:重构预训练、零样本自动微调、一键调用OPT

Pytorch learning 1 (learning documents on the official website)
随机推荐
What else can PLM do?
国产数据库乱象
初识云原生安全:云时代的最佳保障
Quickly set up a website to visit foreign countries, set up SS and start BBR to quickly surf the Internet
American chips are hit hard again, and another chip enterprise after Intel will be overtaken by Chinese chips
Type 'image' is not a subtype of type 'imageprovider < object > solution
Intranet learning notes (8)
Debug tool
高德地图IP定位2.0备份
基于 xml 配置文件的入门级 SSM 框架整合
A method to realize automatic renaming of pictures uploaded by WordPress
Implementing springboard agent through SSH port forwarding configuration
#yyds干货盘点# 解决剑指offer:剪绳子(进阶版)
AGCO AI frontier promotion (6.27)
【业务安全03】密码找回业务安全以及接口参数账号修改实例(基于metinfov4.0平台)
Dynamic Networks and Conditional Computation论文简读和代码合集
万物互联时代到来,锐捷发布场景化无线零漫游方案
爱可可AI前沿推介(6.27)
面试官:Redis的共享对象池了解吗?
Shell 简明教程