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

学网站开发工程师难学吗旅游最新资讯 新闻

学网站开发工程师难学吗,旅游最新资讯 新闻,网站建设图片排版,wordpress中文主题团队文章目录 一、题目A.召唤神坤基本思路:代码 B.聪明的交换策略基本思路:代码 C.怪兽突击基本思路:代码 D.蓝桥快打基本思路代码 一、题目 A.召唤神坤 基本思路: 贪心, 使结果最大,希望两边w[i],w[k]是较大…

文章目录

  • 一、题目
    • A.召唤神坤
      • 基本思路:
      • 代码
    • B.聪明的交换策略
      • 基本思路:
      • 代码
    • C.怪兽突击
      • 基本思路:
      • 代码
    • D.蓝桥快打
      • 基本思路
      • 代码


一、题目

A.召唤神坤

基本思路:

  • 贪心, 使结果最大,希望两边w[i],w[k]是较大的,中间w[j]是较小的

代码

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
#define int long long
#define repn(i,a,n) for(int i = a; i <= n; i++)
#define rep(i,a,n) for(int i = a; i < n; i++)
typedef pair<int,int> PII; 
const int N = 2e6+10;
int n,a[N],b[N];void solve(){cin>>n;repn(i,1,n) cin>>a[i];//贪心, 使结果最大,希望两边w[i],w[k]是较大的,中间w[j]是较小的//先算出并保存第i个元素右边的最大值 for(int i=n;i;i--) b[i]=max(b[i+1],a[i]);
//	for(int i=n;i;i--) cout<<b[i]<<' ';
//	cout<<endl;int res=0,maxn=a[1];repn(i,2,n){res=max(res,(maxn+b[i+1])/a[i]);//枚举a[i],取结果较大值 maxn=max(maxn,a[i]);//更新i左边的最大值 }cout<<res;
}signed main(){
//	IOS;int T=1;
//	cin>>T;while(T--){solve();}return 0;
}

B.聪明的交换策略

基本思路:

  • 这些盒子最后的状态一定是左边都是1右边都是0,或者右边都是1左边都是0。
  • 我们不妨将1都移动到左边或者将1都移动右边,去两者花费次数较小的即为最小交换次数。

代码

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
#define int long long
#define repn(i,a,n) for(int i = a; i <= n; i++)
#define rep(i,a,n) for(int i = a; i < n; i++)
typedef pair<int,int> PII; 
const int N = 1e5+10;
int n;void solve(){cin>>n;string s;cin>>s; s=" "+s;//将所有的'1'向左移和向右移,取两者花费较小的//当然这里的移动不是真的交换位置,而是模拟移动的过程 int ans=1e15,l=1,r=n,res=0;//ans一定要足够大!!!血的教训,比赛时调了半天才发现是这里的错误T_T //l表示左边已经确定位置的元素,每移动一个元素l++。r同理 repn(i,1,n)if(s[i]=='1'){res+=(i-l);l++;}ans=min(ans,res);//将1都移动到右边 res=0;for(int i=n;i>=1;i--)if(s[i]=='1'){res+=(r-i);r--;}ans=min(ans,res);cout<<ans<<endl;
}signed main(){
//	IOS;int T=1;
//	cin>>T;while(T--){solve();}return 0;
}

C.怪兽突击

基本思路:

  • 贪心的思想,我们取前i个元素,剩下的取k-i个前i个元素中的b的最小值 。这样就能找到所有情况,取较小值即可。

代码

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
#define int long long
#define repn(i,a,n) for(int i = a; i <= n; i++)
#define rep(i,a,n) for(int i = a; i < n; i++)
typedef pair<int,int> PII; 
const int N = 1e6+10;
int a[N],b[N];void solve(){int n,k,ans=1e15,minn=1e15,res=0;cin>>n>>k;repn(i,1,n)  cin>>a[i];repn(i,1,n)  cin>>b[i],b[i]+=a[i];//答案一定在取前i个元素,剩下的取k-i个前i个元素中的b的最小值 repn(i,1,min(k,n)){res+=a[i];minn=min(minn,b[i]);//每次保存前面的最小值 ans=min(ans,res+(k-i)*minn);//取前i个元素a1~an,剩下的k-i次取最小值 
//		cout<<minn<<' '<<res<<' '<<ans<<endl;}cout<<ans<<endl;
}signed main(){
//	IOS;int T=1;
//	cin>>T;while(T--){solve();}return 0;
}

D.蓝桥快打

基本思路

  • 找出多方需要多少次打败自己,记住要向上取整,这里用来向上取整函数ceil();

代码

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl "\n"
#define int long long
#define repn(i,a,n) for(int i = a; i <= n; i++)
#define rep(i,a,n) for(int i = a; i < n; i++)
typedef pair<int,int> PII; 
const int N = 1e5+10;
int a,b,c;void solve(){cin>>a>>b>>c;int k=ceil(1.0*a/c);//对方需要多少次打败自己 int res=ceil(1.0*b/k);//自己以最小的攻击力打对方多少次能打败对面 cout<<res<<endl;
}signed main(){
//	IOS;int T=1;cin>>T;while(T--){solve();}return 0;
}
http://www.hkea.cn/news/853837/

相关文章:

  • 搭建网站做淘宝客网赌怎么推广拉客户
  • 网站建设前台与后台最新技术2021最新免费的推广引流软件
  • 做网站基本语言淘宝如何提升关键词排名
  • wordpress怎样分类目录添加标签seo文章范文
  • 订阅号可以做网站吗南宁seo外包服务商
  • 邢台哪儿做网站便宜宁波 seo排名公司
  • 深圳网站优化咨询网上广告怎么推广
  • 网站右击无效是怎么做的网络营销产品
  • 中宣部网站政治建设网站服务器是什么意思
  • 淮安网站定制徐州seo外包公司
  • 嘉兴类网站系统总部网站建设技术解决方案
  • 做网站的教科书外包网络推广公司推广网站
  • 模板名字 wordpress优化大师如何删掉多余的学生
  • 3d网站建设制作百度关键词优化手段
  • 新手做那些网站比较好东莞企业网站排名
  • 欧美风格网站360指数
  • 优秀网站建设公司电话下列哪些店铺适合交换友情链接
  • 58同城乌鲁木齐网站建设重庆网站到首页排名
  • wordpress知言主题山东服务好的seo公司
  • 旅游商务平台网站建设功能需求关键词排名查询官网
  • 做网站要搭建本地服务器么微商引流被加方法精准客源
  • 网站名字要备案吗友情链接怎么弄
  • 江苏网站开发外链网站大全
  • 网站代备案流程图百度关键词优化排名技巧
  • 石狮建设局网站今日头条站长平台
  • 修改公司网站网页站长素材音效
  • 网站速度测速免费访问国外网站的app
  • 常州网站搭建公司宣传推广渠道有哪些
  • 中国建设监理网站广告网络
  • 网站维护费用怎么收路由优化大师官网