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

咸阳做网站公司安平县护栏网站建设

咸阳做网站公司,安平县护栏网站建设,可以看国外网站的dns,做网站有哪些要求枚举中点x( 即选出的三个点 a , b , c 满足 dist( x , a ) dist( x , b ) dist( x , c ) ) , 然后以 x 为 root 做 dfs , 显然两个位于 x 的同一颗子树内的点是不可能被同时选到的 . 我们对 x 的每一颗子树进行 dfs , 记录下当前子树中的点到 x 距离为 d ( 1 d n )…枚举中点x( 即选出的三个点 a , b , c 满足 dist( x , a ) dist( x , b ) dist( x , c ) ) , 然后以 x 为 root 做 dfs , 显然两个位于 x 的同一颗子树内的点是不可能被同时选到的 . 我们对 x 的每一颗子树进行 dfs , 记录下当前子树中的点到 x 距离为 d ( 1 d n ) 有多少个 , 记为 cnt[ 0 ][ i ] . 然后 cnt[ 1 ][ i ] 记录之前 dfs 过的子树的 cnt[ 0 ][ i ] 之和 , cnt[ 2 ][ i ] 记录之前 dfs 过的子树中任意两颗不同子树中的cnt[ 0 ][ i ] * cnt[ 0 ][ i ] 之和 . cnt[  ][ i ] 的计算看代码----------------------------------------------------------------------------#includecstdio#includecstdlib#includecstring#includealgorithm#includeiostream#define clr( x , c ) memset( x , c , sizeof( x ) )#define rep( i , n ) for( int i 0 ; i n ; i )#define REP( x ) for( edge* e head[ x ] ; e ; e e - next )using namespace std;typedef long long ll;const int maxn 5000 5;ll cnt[ 3 ][ maxn ];int n;struct edge {int to;edge* next;} E[ maxn 1 ] , *pt E , *head[ maxn ];inline void add_edge( int u , int v ) {pt - to v;pt - next head[ u ];head[ u ] pt;pt - to u;pt - next head[ v ];head[ v ] pt;}int dfs( int x , int fa , int d ) {cnt[ 0 ][ d ];REP( x ) if( e - to ! fa )     dfs( e - to , x , d );}void work() {ll ans 0;rep( i , n ) {clr( cnt[ 1 ] , 0 );clr( cnt[ 2 ] , 0 );REP( i ) {clr( cnt[ 0 ] , 0 );dfs( e - to , i , 1 );rep( i , n ) {ans cnt[ 0 ][ i ] * cnt[ 2 ][ i ];cnt[ 2 ][ i ] cnt[ 0 ][ i ] * cnt[ 1 ][ i ];cnt[ 1 ][ i ] cnt[ 0 ][ i ];}}}printf( %lld\n , ans );}void init() {clr( head , 0 );cin n;rep( i , n - 1 ) {int u , v , d;scanf( %d%d , u , v );add_edge( --u , --v );}}int main() {freopen( test.in , r , stdin );init();work();    return 0; }   ---------------------------------------------------------------------------- 3522: [Poi2014]HotelTime Limit: 20 Sec  Memory Limit: 128 MBSubmit: 273  Solved: 132[Submit][Status][Discuss]Description有一个树形结构的宾馆n个房间n-1条无向边每条边的长度相同任意两个房间可以相互到达。吉丽要给他的三个妹子各开一个房间。三个妹子住的房间要互不相同否则要打起来了为了让吉丽满意你需要让三个房间两两距离相同。有多少种方案能让吉丽满意Input第一行一个数n。接下来n-1行每行两个数x,y表示x和y之间有一条边相连。Output让吉丽满意的方案数。Sample Input7 1 2 5 7 2 5 2 3 5 6 4 5Sample Output5HINT【样例解释】{1,3,5},{2,4,6},{2,4,7},{2,6,7},{4,6,7}【数据范围】n≤5000SourceBy Dzy 转载于:https://www.cnblogs.com/JSZX11556/p/4643812.html
http://www.pierceye.com/news/248339/

相关文章:

  • 网站备案后经营做网站实例教程
  • 软件网站怎么做的python下载安装教程
  • 旅游网站开发分析报告网站建设教程搭建芽嘱湖南岚鸿信赖
  • 网站的配色方案高校网站建设意义
  • 滇中引水工程建设管理局网站网站开发怎样验收
  • ps制作网站logo阿里云网站备案拍照
  • 网站建设合同】wordpress翻书
  • 电商网站建设制作隆化县建设局网站
  • 宁波网站建设rswl网页美工设计教案
  • 贵州省住房城乡建设部网站json网站开发
  • 桥头网站仿做百度里面的站长工具怎么取消
  • 博物馆网站页面设计说明山东高端网站定制
  • python网站开发效率jsp做网站下载图片
  • 营销式网站建设免费注册个人网站官网
  • 高职高专 网站建设与维护开发一个网站平台多少钱
  • 网站后缀有哪些宜昌建设网站
  • iis做网站的流程wordpress有中文版没
  • 一般的美工可以做网站吗网站做相册
  • 扁平化网站psd招聘类网站怎么做
  • 想当淘客自己的网站怎么做服装网页设计网站
  • 网站怎么做数据接口wordpress主题知更
  • 注册网站登录企业网站建设论文模板
  • 营销型网站模板免费下载常用wordpress搭建环境
  • 浦东新区手机网站建设wordpress 视频页面
  • 做课件最好的素材网站网站背景动图怎么做
  • 做网站时已做好了ps怎么倒入深圳燃气公司地址
  • 做类似淘宝的网站要多少钱亚马逊网站建设进度计划书
  • 够完美网站建设怎么把视频弄成超链接
  • 苏州网站建设哪家更好四川省建设工程信息网官网二建注册
  • 潍坊网站关键词推广湖南餐饮网站建设