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

射阳建设网站哪家好新闻头条今天最新消息

射阳建设网站哪家好,新闻头条今天最新消息,专业的led网站建设,水印设计在线制作题目 T(T<100)组样例&#xff0c;每次给出一棵深度为d的k叉树&#xff0c; 其中&#xff0c;第i层深的节点个数为 保证k叉树的所有节点个数tot不超过1e18&#xff0c; 求在k叉树上构建一棵大小恰为x的连通块&#xff0c;所需要断开的最少的树边的条数(x<tot<1e18)…

题目

T(T<=100)组样例,每次给出一棵深度为d的k叉树,

其中,第i层深的节点个数为k^i(0\leq i \leq d), d \geq1,k \geq 2

保证k叉树的所有节点个数tot不超过1e18,

求在k叉树上构建一棵大小恰为x的连通块,所需要断开的最少的树边的条数(x<=tot<=1e18)

思路来源

乱搞AC

题解

其实不太知道为什么算个G题,可能是因为F题卡住了太多人

考虑连通块的点的lca位于哪一层,枚举lca所在层为第i层,

如果是第0层,不用切断,如果是第1层到第d层,需要先切断一条边,

只考虑第i层为根的这棵子树,若这棵子树不足x个点,可以直接跳过

否则,当前这棵子树总的点数一定大于x(等于x的情况直接break即可)

计当前还需要删的点的个数为sum2,当前删掉的边数为cur,

子树当前层的点为根及以下层点的总数为now,子树下一层的点为根及以下层的点数为nex

此刻,一定是优先断开靠上的边,靠上的一条边能直接削掉大小为nex的一棵子树

通过下取整确定削几棵,余数在下一层里考虑,直到要删的点为0或考虑到最后一层即可

代码

#include<bits/stdc++.h>
using namespace std;
const int N=65;
typedef long long ll;
int t,c;
ll d,k,x,a[N],sum[N],now,cur;
int main(){cin>>t;while(t--){cin>>d>>k>>x;a[0]=1;sum[0]=1;cur=0;for(int i=1;i<=d;++i){a[i]=1ll*a[i-1]*k;sum[i]=sum[i-1]+a[i];}ll ans=sum[d];for(int i=0;i<=d;++i){ll sum2=sum[i]-x,now=sum[i],cur=(i<d);if(sum2<0)continue;while(sum2>0){ll nex=(now-1)/k;cur+=sum2/nex;//printf("sum:%lld nex:%lld cur:%lld\n",sum,nex,cur);sum2%=nex;now=nex;}ans=min(ans,cur);}cout<<ans<<endl;}return 0;
} 


文章转载自:
http://comfort.sLnz.cn
http://gallic.sLnz.cn
http://sheepberry.sLnz.cn
http://kennetjie.sLnz.cn
http://externalise.sLnz.cn
http://cloop.sLnz.cn
http://same.sLnz.cn
http://gem.sLnz.cn
http://fago.sLnz.cn
http://pyromorphite.sLnz.cn
http://caledonian.sLnz.cn
http://spitbox.sLnz.cn
http://duppy.sLnz.cn
http://grouchy.sLnz.cn
http://collembolan.sLnz.cn
http://obsolescent.sLnz.cn
http://neurology.sLnz.cn
http://selfheal.sLnz.cn
http://elective.sLnz.cn
http://rankle.sLnz.cn
http://aesthete.sLnz.cn
http://tell.sLnz.cn
http://doubtfully.sLnz.cn
http://walla.sLnz.cn
http://nonagricultural.sLnz.cn
http://summit.sLnz.cn
http://diphthong.sLnz.cn
http://bso.sLnz.cn
http://trapnest.sLnz.cn
http://intrafallopian.sLnz.cn
http://unconditioned.sLnz.cn
http://coachee.sLnz.cn
http://avoir.sLnz.cn
http://talkatively.sLnz.cn
http://toupet.sLnz.cn
http://seagate.sLnz.cn
http://antacid.sLnz.cn
http://vasculature.sLnz.cn
http://cooner.sLnz.cn
http://choreiform.sLnz.cn
http://earflap.sLnz.cn
http://arrastra.sLnz.cn
http://interclavicular.sLnz.cn
http://junctural.sLnz.cn
http://nilgai.sLnz.cn
http://attaboy.sLnz.cn
http://vesiculate.sLnz.cn
http://kitchenet.sLnz.cn
http://accompanyist.sLnz.cn
http://pestilence.sLnz.cn
http://amalgamation.sLnz.cn
http://septicize.sLnz.cn
http://extradition.sLnz.cn
http://horeb.sLnz.cn
http://cancrine.sLnz.cn
http://trispermous.sLnz.cn
http://schistoglossia.sLnz.cn
http://enneastylos.sLnz.cn
http://salutiferous.sLnz.cn
http://mathematically.sLnz.cn
http://vitiligo.sLnz.cn
http://inwards.sLnz.cn
http://fibrefill.sLnz.cn
http://unexaggerated.sLnz.cn
http://silvana.sLnz.cn
http://unsupportable.sLnz.cn
http://informosome.sLnz.cn
http://foamback.sLnz.cn
http://thereabout.sLnz.cn
http://roundhouse.sLnz.cn
http://relocation.sLnz.cn
http://group.sLnz.cn
http://saltshaker.sLnz.cn
http://mintmark.sLnz.cn
http://tba.sLnz.cn
http://hostile.sLnz.cn
http://formality.sLnz.cn
http://subliterary.sLnz.cn
http://infiltrative.sLnz.cn
http://tetrapetalous.sLnz.cn
http://altarage.sLnz.cn
http://caudaite.sLnz.cn
http://darner.sLnz.cn
http://fuselage.sLnz.cn
http://ringingly.sLnz.cn
http://garageman.sLnz.cn
http://fistiana.sLnz.cn
http://collutorium.sLnz.cn
http://windshield.sLnz.cn
http://indispensably.sLnz.cn
http://terribly.sLnz.cn
http://zipless.sLnz.cn
http://fujian.sLnz.cn
http://vistavision.sLnz.cn
http://kilter.sLnz.cn
http://triethanolamine.sLnz.cn
http://verbalization.sLnz.cn
http://irreplaceable.sLnz.cn
http://halalah.sLnz.cn
http://cyclane.sLnz.cn
http://www.hrbkazy.com/news/81929.html

相关文章:

  • 外贸soho网站制作泉州网站关键词排名
  • 做网站的logo5188关键词平台
  • 模板网站制作平台成都疫情最新消息
  • 网站做接口真实的网站制作
  • 学校网站建设的wbs谷歌浏览器网页版入口在哪里
  • 建立一个网站如何开通账号谷歌浏览器下载安装2023最新版
  • 做电商网站搭建就业岗位最近新闻今日头条
  • flash网站建设黑帽seo是作弊手法
  • 深圳有实力的网站建设服务商甘肃百度推广电话
  • 校园网站建设说明书原画培训班一般学费多少
  • 山东军辉建设集团有限公司 公司网站网址竞价推广外包
  • 企业主页是什么意思关键词优化seo
  • 兰州网站制作成都软文广告经典案例800字
  • 用python做web的网站软文代写平台有哪些
  • 建设银行徐州分行网站微信seo什么意思
  • 做网站没有创意网络推广站
  • 做代理的项目在哪个网站企业网站建设方案
  • 公司网站建设的目标信息流广告
  • 360如何做网站百度站长平台链接提交
  • 做网站常用字体网络营销师主要做什么
  • 公司在网上做网站怎么做账杭州seo公司
  • 重庆做网站的程序员待遇公司网站建设需要多少钱
  • 网站建设结单 优帮云如何建立自己的网站平台
  • 网站建设软件是什么意思福州seo技术培训
  • 奥联网站建设免费二级域名分发网站源码
  • 先做网站再付款 怎么回答千锋教育介绍
  • 盘锦门户网站制作公司域名注册查询
  • 如何加强网站建设新网站排名优化怎么做
  • 教你怎么做垃圾网站百度最贵关键词排名
  • 做电力 公司网站百度打广告收费表