博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 4786 Fibonacci Tree(最小生成树)
阅读量:5989 次
发布时间:2019-06-20

本文共 1729 字,大约阅读时间需要 5 分钟。

Fibonacci Tree

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2952    Accepted Submission(s): 947
Problem Description
  Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem:
  Consider a bidirectional graph G with N vertices and M edges. All edges are painted into either white or black. Can we find a Spanning Tree with some positive Fibonacci number of white edges?

(Fibonacci number is defined as 1, 2, 3, 5, 8, ... )

 
Input
  The first line of the input contains an integer T, the number of test cases.
  For each test case, the first line contains two integers N(1 <= N <= 10
5) and M(0 <= M <= 10
5).
  Then M lines follow, each contains three integers u, v (1 <= u,v <= N, u<> v) and c (0 <= c <= 1), indicating an edge between u and v with a color c (1 for white and 0 for black).
 
Output
  For each test case, output a line “Case #x: s”. x is the case number and s is either “Yes” or “No” (without quotes) representing the answer to the problem.
 
Sample Input
 
2 4 4 1 2 1 2 3 1 3 4 1 1 4 0 5 6 1 2 1 1 3 1 1 4 1 1 5 1 3 5 1 4 2 1
 
Sample Output
 
Case #1: Yes Case #2: No
 
Source

有n个点,m条边。有黑白之分,问连通全部点时的边中,白边的个数能不能是斐波那契数列中的一个数

思路:先用白边连图。求出白边的个数,再先用黑边连图,求出白边另个值,。这两个值就是白边个数的取值范围 
2015,7,30 

#include
#include
#include
using namespace std;#define M 100000+10struct node{ int s,e,val;}sd[M];int x[M];int a[55];bool cmp1(node a,node b){ return a.val>b.val;}bool cmp2(node a,node b){ return a.val
= start && a[i]<=end){ ok=1; break; } } if(ok) printf("Yes\n"); else printf("No\n"); } } return 0;}

转载地址:http://uajlx.baihongyu.com/

你可能感兴趣的文章
浅谈虚拟化技术的含义及分类
查看>>
linux编译安装nginx
查看>>
PostgreSQL Oracle 兼容性之 - rownum
查看>>
mysql 主从与binlog
查看>>
在indesign中如何分栏
查看>>
如何在Evolution中加密(五)
查看>>
java中的参数传递
查看>>
iOS之Storyboard导航大揭秘(1)
查看>>
家用PC机打造VSphere5.1 测试环境: 之测试虚拟机
查看>>
远程调试 Azure Web App
查看>>
Vmware vSphere 5.0系列教程之三 vCenter介绍及安装配置
查看>>
OpenExpressApp make business engineers develop applications
查看>>
《WCF技术内幕》翻译18:第1部分_第4章_WCF101:从外部剖析WCF
查看>>
《机器学习实战》k最近邻算法(K-Nearest Neighbor,Python实现)
查看>>
中小企业管理解决方案
查看>>
一步一步学Silverlight 2系列(9):使用控件模板
查看>>
企业架构 - 组织角色和技能
查看>>
Exchange Server2010系列之十二:部署及配置邮箱高可用DAG
查看>>
mssql 字增自段怎样重置(重新自增)|清空表已有数据
查看>>
Trojan.DL.Win32.Hmir.hl的清除方法 采用驱动提供服务的木马病毒
查看>>