您当前的位置: 首页 > 

先求一个导

暂无认证

  • 2浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

牛客练习赛96 B

先求一个导 发布时间:2022-02-24 22:35:20 ,浏览量:2

题目 题意: 求一颗n层的满k叉树,求任意两点之间距离和等于多少. 思路: 可以暴力也可以推公式,不会推。暴力做法为,对于同一层的每条边,贡献相同。而该边的贡献为cnt左边的点 * cnt右边的点. 在这里插入图片描述

时间复杂度: O(n) 代码:

// Problem: 小y的树
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/11186/B
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i            
关注
打赏
1662037414
查看更多评论
0.0369s