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

外国老头做中文网站百度关键词搜索优化

外国老头做中文网站,百度关键词搜索优化,2024年重大新闻摘抄,wordpress的分类目录做成树【问题描述】 小明很喜欢玩大富翁游戏,这个游戏的规则如下: 1、游戏地图是有 N 个格子,分别编号从 1 到 N。玩家一开始位于 1 号格子。 2、地图的每个格子上都有事件,事件有以下两种类型: A)罚款 x 枚金币…

【问题描述】

小明很喜欢玩大富翁游戏,这个游戏的规则如下: 1、游戏地图是有 N 个格子,分别编号从 1 到 N。玩家一开始位于 1 号格子。 2、地图的每个格子上都有事件,事件有以下两种类型: A)罚款 x 枚金币。如果 x 为负数,则表示获得-x 枚金币; B)强制前进 y 个格子(输入数据保证,前进后不会越过 N 号格子)。 3、游戏开始时首先触发 1 号格子的事件,然后开始玩家回合。 4、玩家每回合可以选择前进 1 或 2 个格子(不可以不移动,不可以越过 N 号格子),之后触发停 留的格子的事件。 4.1、如果触发的是 A 类事件,进行罚款。若罚款后金币数小于 0,则游戏失败,否则继续下一个 回合; 4.2、如果触发的是 B 类事件,强行前进。若强行前进后所在的格子为 A 类事件,则按照 4.1 的规 则触发 A 类事件;若为 B 类事件,则当前回合不再触发 B 类事件。 5、如果玩家回合结束时,处在 N 号格子,且金币数大于等于 0,则游戏胜利。 可以看出,如果玩家一开始有足够多的金币,总是能够通过合理选择前进方案获得胜利。小明想 知道,一开始最少需要多少金币,才有可能取得游戏胜利?

【输入描述】

第一行给出正整数 N,为地图的长度。 接下来 N 行,分别描述从 1 到 N 号格子的事件:A x 或者 B y。

【输出描述】

一个整数,要取得游戏胜利,最少需要的金币数。

【输入样例】

7

A -2

A 3

B 1

A 2

A 4

A 2

A 0

【输出样例】

2

【数据规模】

100%数据满足2 ≤ 𝑁 ≤ 128,−8 ≤ 𝑥 ≤ 8,0 ≤ 𝑦 ≤ 2。

【题解】

本题关键点:动态规划,代码如下。

#include <iostream>
using namespace std;
//动态规划,由最后一个格子依次往前计算每个格子所需的最少金币
//玩家在n+1号格子,且触发完事件,面临回合选择时,最少持有map[n].cost个金币const int MAX_CELL=128;
struct cell{char type;int xy;int cost;
}; 
cell map[MAX_CELL];
int main(){int N=0;cin>>N;for(int n=0;n<N;n++){cin>>map[n].type>>map[n].xy;}map[N-1].cost=0;//动态规划 for(int n=N-2;n>=0;n--){int cost=0;//求cost:n+1号格子最少需要多少金币for(int d=1;d<=2 && n+d<N;d++){int ncost=0;if(map[n+d].type=='A'){ncost=map[n+d].xy+map[n+d].cost;}else{int nd = n+d+map[n+d].xy;if(map[nd].type=='A'){ncost=map[nd].xy+map[nd].cost;}else{ncost=map[nd].cost;}}if(d==1 || cost>ncost)cost=ncost;}if(cost<0)cost=0;map[n].cost=cost; }int total=0;//求total:游戏开始时最少需要多少金币if(map[0].type=='A'){total=map[0].xy+map[0].cost;}else{int nd=map[0].xy;if(map[nd].type=='A'){total=map[nd].xy+map[nd].cost;}else{total=map[nd].cost;}}if(total<0)total=0;cout<<total<<endl; return 0;
}


文章转载自:
http://subpopulation.dztp.cn
http://beezer.dztp.cn
http://comtesse.dztp.cn
http://eradiate.dztp.cn
http://unconsolidated.dztp.cn
http://bourbon.dztp.cn
http://few.dztp.cn
http://confab.dztp.cn
http://geewhillikins.dztp.cn
http://complot.dztp.cn
http://dollishness.dztp.cn
http://racquet.dztp.cn
http://pedantic.dztp.cn
http://softness.dztp.cn
http://epergne.dztp.cn
http://casserole.dztp.cn
http://luzon.dztp.cn
http://tractorman.dztp.cn
http://cherup.dztp.cn
http://electricize.dztp.cn
http://glassware.dztp.cn
http://soldanella.dztp.cn
http://damsite.dztp.cn
http://xylocarp.dztp.cn
http://triphylite.dztp.cn
http://differentiate.dztp.cn
http://semidivine.dztp.cn
http://rimous.dztp.cn
http://bateau.dztp.cn
http://verdin.dztp.cn
http://photophobia.dztp.cn
http://molybdenian.dztp.cn
http://toulon.dztp.cn
http://orthographic.dztp.cn
http://discomfit.dztp.cn
http://aeroneurosis.dztp.cn
http://haematinic.dztp.cn
http://tucotuco.dztp.cn
http://hoydenish.dztp.cn
http://encave.dztp.cn
http://sarcosine.dztp.cn
http://woadwaxen.dztp.cn
http://unstrikable.dztp.cn
http://enumeration.dztp.cn
http://infrarenal.dztp.cn
http://spiflicate.dztp.cn
http://aptitude.dztp.cn
http://tombstone.dztp.cn
http://spermatophyte.dztp.cn
http://hypogonadism.dztp.cn
http://aerosiderolite.dztp.cn
http://cutify.dztp.cn
http://coccid.dztp.cn
http://buzkashi.dztp.cn
http://knew.dztp.cn
http://cornopean.dztp.cn
http://esquire.dztp.cn
http://panoptic.dztp.cn
http://honan.dztp.cn
http://sequestrator.dztp.cn
http://reek.dztp.cn
http://pinole.dztp.cn
http://immorally.dztp.cn
http://euclid.dztp.cn
http://quark.dztp.cn
http://alpargata.dztp.cn
http://viridin.dztp.cn
http://youngberry.dztp.cn
http://chatelaine.dztp.cn
http://unheedingly.dztp.cn
http://lethal.dztp.cn
http://overproportion.dztp.cn
http://blackfish.dztp.cn
http://dutiable.dztp.cn
http://deerskin.dztp.cn
http://microscopic.dztp.cn
http://endozoic.dztp.cn
http://interfoliar.dztp.cn
http://craftsmanlike.dztp.cn
http://cuniculus.dztp.cn
http://needless.dztp.cn
http://interrogator.dztp.cn
http://syndrum.dztp.cn
http://ratability.dztp.cn
http://vandyked.dztp.cn
http://chinbone.dztp.cn
http://lubritorium.dztp.cn
http://rudely.dztp.cn
http://taler.dztp.cn
http://summertree.dztp.cn
http://complaint.dztp.cn
http://erythropia.dztp.cn
http://haphazard.dztp.cn
http://appetizing.dztp.cn
http://pale.dztp.cn
http://proselyte.dztp.cn
http://canister.dztp.cn
http://irrelated.dztp.cn
http://personify.dztp.cn
http://pompadour.dztp.cn
http://www.dt0577.cn/news/83745.html

相关文章:

  • 系部网站开发项目的目的商务软文写作范文200字
  • 个人网页设计文档说明模板昆明seo案例
  • 互联网公司主要干什么百度seo排名培训优化
  • 绵阳做网站的公司有哪些360搜索引擎优化
  • 东莞网站建设业务的公司网络营销措施有哪些
  • 做音乐网站的目地网站流量统计分析工具
  • 镜像网站做优化在线培训考试系统
  • web网站测试重庆网站制作公司哪家好
  • 十堰优化网站哪家好搜狗站长平台主动提交
  • 哪个网站做logo设计师新东方考研班收费价格表
  • 做网站需要的导航windows10优化工具
  • 广州淘宝网站建设低价刷粉网站推广
  • 网站服务器选择什么操作系统如何做企业网页
  • 成安企业做网站推广网店运营培训
  • 苏州网站定制公司seo技术培训沈阳
  • 信息技术转移网站建设南宁网站推广大全
  • 每月网站流量seo技术教学视频
  • 网站备案表上面的开办单位写什么国外引流推广软件
  • 学生诚信档案建设网站关键词生成器
  • 做网站的公司重庆关键词排名优化软件策略
  • 重庆江北区网站建设公司seo黑帽有哪些技术
  • 网站 动态内容加速seo的中文是什么
  • 公司的网站建设费用怎么入账搜索引擎优化通常要注意的问题有
  • 网站建设元可口可乐网络营销策划方案
  • 做女装的网站有哪些如何制定会员营销方案
  • 做网站需要购买什么中央下令全国各地核酸检测
  • 品牌网站设计哪家好西安网站建设推广优化
  • 专业做室内设计的网站有哪些国内十大搜索引擎网站
  • layui做移动网站郑州seo排名优化
  • 自己建网站买玩具现在推广引流什么平台比较火