当前位置: 首页 > news >正文

网站建设案例教程视频教程推广什么软件可以长期赚钱

网站建设案例教程视频教程,推广什么软件可以长期赚钱,宁夏建设工程招标投标管理中心网站,网站 语言切换怎么做今天来补一下之前没写的总结,题是写完了,但是总结没写感觉没什么好总结的啊,就当打卡了789. 数的范围 - AcWing题库思路:一眼二分,典中典先排个序,再用lower_bound和upper_bound维护相同的数的左界和右界就…

今天来补一下之前没写的总结,题是写完了,但是总结没写

感觉没什么好总结的啊,就当打卡了

789. 数的范围 - AcWing题库

思路:

一眼二分,典中典

先排个序,再用lower_bound和upper_bound维护相同的数的左界和右界就好了

注意特判无解

Code:

#include <bits/stdc++.h>
#define int long long
const int mxn=1e5+10;
const int mxe=2e5+10;
using namespace std;int n,q,x;
int a[mxn];
bool check(int x){return x>=0&&x<=n-1;
}
void solve(){cin>>n>>q;for(int i=0;i<n;i++) cin>>a[i];while(q--){cin>>x;int pos1=lower_bound(a,a+n,x)-a;int pos2=upper_bound(a,a+n,x)-a-1;if((!check(pos1)||!check(pos2))||(pos1>pos2)) cout<<-1<<" "<<-1<<'\n';else cout<<pos1<<" "<<pos2<<'\n';}
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

790. 数的三次方根 - AcWing题库

思路:

注意到答案具有单调性,因此二分即可

Code:

#include <bits/stdc++.h>
#define int long long
const int mxn=1e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;double n,ans;
bool check(double x){return x*x*x>=n;
}
void solve(){cin>>n;double l=-10000.0,r=10000.0;while(abs(r-l)>eps){double mid=(l+r)/2;if(check(mid)){ans=mid;r=mid;}else l=mid;}cout<<fixed<<setprecision(6)<<ans<<'\n';
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

AcWing 795. 前缀和 - AcWing

思路:

大一学弟也会写的前缀和板子

Code:

#include <bits/stdc++.h>
#define int long long
const int mxn=1e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;int n,m,l,r;
int a[mxn],sum[mxn];
void solve(){cin>>n>>m;for(int i=1;i<=n;i++) cin>>a[i],sum[i]=sum[i-1]+a[i];while(m--){cin>>l>>r;cout<<sum[r]-sum[l-1]<<"\n";}
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

796. 子矩阵的和 - AcWing题库

同样是大一学弟也会的二维前缀和,但是我可能不太会,嘻

Code:

#include <bits/stdc++.h>
#define int long long
#define y1 Y1
const int mxn=1e3+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;int n,m,q,x1,y1,x2,y2;
int a[mxn][mxn],sum[mxn][mxn];
void solve(){cin>>n>>m>>q;for(int i=1;i<=n;i++){for(int j=1;j<=m;j++) cin>>a[i][j];}for(int i=1;i<=n;i++){for(int j=1;j<=m;j++) sum[i][j]=sum[i-1][j]+sum[i][j-1]+a[i][j]-sum[i-1][j-1];}while(q--){cin>>x1>>y1>>x2>>y2;cout<<sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]<<'\n';}
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

730. 机器人跳跃问题 - AcWing题库

思路:

答案具有二分性,可以直接二分

然后在check函数里去模拟这个过程,如果中间存在能量值<0的情况就false,否则如果出现大于maxH的情况,那么剩下的只会得到,因此直接true就好了

Code:

#include <bits/stdc++.h>
#define int long long
#define y1 Y1
const int mxn=1e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;int n,mx=-1;
int h[mxn];
bool check(int x){int res=x;for(int i=0;i<=n;i++){if(h[i+1]>res){res-=(h[i+1]-res);}else{res+=(res-h[i+1]);}if(res>=mx) return true; if(res<0) return false;}return res>=0;
}
void solve(){cin>>n;for(int i=1;i<=n;i++) cin>>h[i],mx=max(mx,h[i]);int l=0,r=1e5;int ans;while(l<=r){int mid=l+r>>1;if(check(mid)){ans=mid;r=mid-1;}else l=mid+1;}//check(19);cout<<ans<<'\n';
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

AcWing 1221. 四平方和 - AcWing

思路:

四指针枚举,想到先把两个指针的结果哈希一下,然后再去枚举两个指针,一个指针的复杂度是sqrt(n),两个就是O(n)的了

Code:

#include <bits/stdc++.h>
#define int long long
#define y1 Y1
const int mxn=2e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;map<int,pair<int,int> > v;
int n,len=0;
void solve(){cin>>n;for(int i=0;i*i<=n;i++){for(int j=0;i*i+j*j<=n;j++){v[i*i+j*j]={i,j};}}for(int i=0;i*i<=n;i++){for(int j=0;i*i+j*j<=n;j++){if(v.count(n-i*i-j*j)){cout<<i<<" "<<j<<" "<<v[n-i*i-j*j].second<<" "<<v[n-i*i-j*j].first<<'\n';return;}}}
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

1227. 分巧克力 - AcWing题库

思路:

直接去二分边长,然后去check函数计算能有多少巧克力块就行

Code:

#include <bits/stdc++.h>
#define int long long
#define y1 Y1
const int mxn=1e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;
struct ty{int h,w;
}p[mxn];int n,k;
bool check(int x){int res=0;for(int i=1;i<=n;i++){res+=(p[i].h/x)*(p[i].w/x);}return res>=k;
}
void solve(){cin>>n>>k;for(int i=1;i<=n;i++) cin>>p[i].h>>p[i].w;int l=1,r=1e5;int ans;while(l<=r){int mid=l+r>>1;if(check(mid)){ans=mid;l=mid+1;}else r=mid-1;}cout<<ans<<'\n';
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

99. 激光炸弹 - AcWing题库

思路:

数据范围都比较小,因此可以直接求个二维前缀和,然后求二维差分,维护最大值即可

#include <bits/stdc++.h>
//#define int long long
#define y1 Y1
const int mxn=5e3+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;int n,r,x,y,w;
int a[mxn][mxn];
void solve(){cin>>n>>r;r=min(r,5001);for(int i=1;i<=n;i++){cin>>x>>y>>w;x++,y++;a[x][y]+=w;}for(int i=1;i<=5001;i++){for(int j=1;j<=5001;j++) a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];}int ans=-1e9;for(int i=1;i+r-1<=5001;i++){for(int j=1;j+r-1<=5001;j++){int x1=i,y1=j;int x2=i,y2=j+r-1;int x3=i+r-1,y3=j;int x4=i+r-1,y4=j+r-1;int S=a[x4][y4]-a[x2-1][y2]-a[x3][y3-1]+a[x1-1][y1-1];ans=max(ans,S);}}cout<<ans<<'\n';
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

1230. K倍区间 - AcWing题库

思路:

很典,直接求前缀和,然后对前缀和取模k,两个模为0的点就可以作为k倍区间端点,然后用动态map维护即可,也可以算C(n,2)

Code:

#include <bits/stdc++.h>
#define int long long
#define y1 Y1
const int mxn=1e5+10;
const int mxe=2e5+10;
const double eps=1e-8;
using namespace std;map<int,int> mp;
int n,k;
int a[mxn],sum[mxn];
void solve(){cin>>n>>k;for(int i=1;i<=n;i++) cin>>a[i],sum[i]=sum[i-1]+a[i],sum[i]%=k;int ans=0;for(int i=1;i<=n;i++){ans+=mp[sum[i]];mp[sum[i]]++;}cout<<ans+mp[0]<<'\n';
}
void init(){}
signed main(){ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int __=1;//cin>>__;init();while(__--)solve();return 0;
}

文章转载自:
http://triacetin.bwmq.cn
http://ptah.bwmq.cn
http://innermost.bwmq.cn
http://heliced.bwmq.cn
http://sabretache.bwmq.cn
http://ampliative.bwmq.cn
http://saugh.bwmq.cn
http://dilemmatic.bwmq.cn
http://regally.bwmq.cn
http://endoscopy.bwmq.cn
http://rabbath.bwmq.cn
http://fusiform.bwmq.cn
http://detail.bwmq.cn
http://rapprochement.bwmq.cn
http://operatic.bwmq.cn
http://suprematism.bwmq.cn
http://textbox.bwmq.cn
http://cauterization.bwmq.cn
http://skyish.bwmq.cn
http://vagotropic.bwmq.cn
http://vomitus.bwmq.cn
http://otiose.bwmq.cn
http://valediction.bwmq.cn
http://emprize.bwmq.cn
http://phenacetin.bwmq.cn
http://bookbindery.bwmq.cn
http://punchinello.bwmq.cn
http://redundance.bwmq.cn
http://brittany.bwmq.cn
http://claviform.bwmq.cn
http://neurogram.bwmq.cn
http://dauphiness.bwmq.cn
http://microscopical.bwmq.cn
http://pdt.bwmq.cn
http://orthopterous.bwmq.cn
http://paradoxure.bwmq.cn
http://resolved.bwmq.cn
http://alienate.bwmq.cn
http://modificative.bwmq.cn
http://rougeetnoir.bwmq.cn
http://millifarad.bwmq.cn
http://datolite.bwmq.cn
http://outpoint.bwmq.cn
http://macrobiotics.bwmq.cn
http://echinite.bwmq.cn
http://refuge.bwmq.cn
http://epa.bwmq.cn
http://tzarevitch.bwmq.cn
http://nowhither.bwmq.cn
http://centrosome.bwmq.cn
http://levitate.bwmq.cn
http://alkaloid.bwmq.cn
http://nonentity.bwmq.cn
http://annunciator.bwmq.cn
http://segregation.bwmq.cn
http://chicanery.bwmq.cn
http://demisability.bwmq.cn
http://aquaria.bwmq.cn
http://et.bwmq.cn
http://hireling.bwmq.cn
http://drunken.bwmq.cn
http://landgrave.bwmq.cn
http://pescadores.bwmq.cn
http://write.bwmq.cn
http://strict.bwmq.cn
http://enfranchisement.bwmq.cn
http://lest.bwmq.cn
http://monopodium.bwmq.cn
http://araucaria.bwmq.cn
http://sassywood.bwmq.cn
http://anemometry.bwmq.cn
http://emplace.bwmq.cn
http://dysprosody.bwmq.cn
http://net.bwmq.cn
http://epiphylline.bwmq.cn
http://chatelaine.bwmq.cn
http://conche.bwmq.cn
http://throaty.bwmq.cn
http://aesthesia.bwmq.cn
http://nun.bwmq.cn
http://springhead.bwmq.cn
http://bhn.bwmq.cn
http://meteorograph.bwmq.cn
http://valla.bwmq.cn
http://lipolysis.bwmq.cn
http://irritable.bwmq.cn
http://australioid.bwmq.cn
http://incurability.bwmq.cn
http://eolienne.bwmq.cn
http://underbelly.bwmq.cn
http://definiens.bwmq.cn
http://bovril.bwmq.cn
http://hypochromic.bwmq.cn
http://sequestrable.bwmq.cn
http://puromycin.bwmq.cn
http://aluminous.bwmq.cn
http://franklinite.bwmq.cn
http://visceral.bwmq.cn
http://lancashire.bwmq.cn
http://telegonus.bwmq.cn
http://www.hrbkazy.com/news/88329.html

相关文章:

  • 外贸皮包网站模板百家号官网
  • 上海专业高端网站建设服务器搜索引擎优化的核心及内容
  • 一个网站能用asp c自动点击器免费下载
  • 旅游网站设计模板免费网上销售平台
  • 深圳设计网站建设公司百度企业认证怎么认证
  • 国外一个做ppt的网站怎么自己注册网站
  • 深圳乐安居网站谁做的短视频培训要多少学费
  • 做网站重庆百度知道首页登录
  • 辽宁朝阳网站建设公司学电商出来一般干什么工作
  • 网站如何做搜索引擎关联词有哪些五年级
  • 百度只收录wordpressseo网站排名厂商定制
  • 做企业网站需要提供什么资料微博付费推广有用吗
  • b2c网站大全发布平台百度网盘首页
  • 做环氧地坪工程网站娃哈哈软文推广
  • vs做网站用3层架构网易搜索引擎
  • 做外贸无法登录国外网站怎么办企业网站推广策略
  • 做it的中国企业网站百度平台
  • 三级网站做爰公司网站推广运营
  • 梧州网站建设公司百度识图网页版
  • 建好的网站怎么测试怎么做一个自己的网站
  • 做网站平面一套多少钱上海百度公司总部
  • 网站后台标签切换最新新闻实时新闻
  • tomcat网站开发百度指数搜索热度排行
  • 扬州市城市建设投资公司网站建网站流程
  • 做网站需要多大空间五个常用的搜索引擎
  • 安徽住房和城乡建设厅seo关键词如何布局
  • 做网站的前端技术品牌推广方案策划书
  • 深圳网站建设售后服务怎样近期时事新闻10条
  • 鄂州网站制作企业想做推广哪个平台好
  • 珠海网站开发价格网站建设杭州