HDU4736-Fibonacci Tree

http://acm.hdu.edu.cn/showproblem.php?pid=4786

Fibonacci Tree

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2509    Accepted Submission(s): 801


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
 

Recommend
We have carefully selected several similar problems for you:   5177  5176  5175  5173  5172 
 

题目要求:就是在所给的多条边中,判断是否存在一个生成树,使得白色的边数为fibonacci数;
感觉很简单,以白边1和黑边0为权值求一次最小生成数t1和最大生成树t2(数值)。判断在t1~t2间是否有fibonacci数;不能构成生成树的直接输出NO;这里用kruskal求最小(da)生成树.

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>

#define maxn 100000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657

const ull inf = 1LL << 61;
const double eps=1e-5;

using namespace std;

bool cmp(int a,int b){
return a>b;
}
int fb[30];
int fa[maxn];
void f()
{
fb[1]=1;
fb[2]=1;
for(int i=3;i<=30;i++)
fb[i]=fb[i-1]+fb[i-2];
}
void init(int n)
{
for(int i=1;i<=n;i++)
fa[i]=i;
}
int findfa(int x)
{
if(x==fa[x])return x;
else return fa[x]=findfa(fa[x]);
}
void Union(int x,int y)
{
int fa_x=findfa(x);
int fa_y=findfa(y);
fa[fa_x]=fa_y;
}
struct node
{
int u,v,w;
}edge[maxn];
bool cmp1(node a,node b)
{
return a.w<b.w;
}
bool cmp2(node a,node b)
{
return a.w>b.w;
}
int n,m;
int Kruskal(int k)
{
init(n);
if(k==1)sort(edge+1,edge+1+m,cmp1);
if(k==2)sort(edge+1,edge+1+m,cmp2);
int cnt=1;
int ans=0;
for(int i=1;i<=m;i++)
{
if(findfa(edge[i].u)!=findfa(edge[i].v))
{
Union(edge[i].u,edge[i].v);
ans+=edge[i].w;
cnt++;
}
}
if(cnt==n)
{
return ans;
}
else return 0;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;
cin>>t;
f();
for(int i=1;i<=t;i++)
{
cout<<"Case #"<<i<<": ";
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
scanf("%d%d%d",&edge[i].u,&edge[i].v,&edge[i].w);
int t1=Kruskal(1);
int t2=Kruskal(2);
int mark=0;
for(int i=1;fb[i]<=t2;i++)
{
if(t1<=fb[i]&&fb[i]<=t2){mark=1;cout<<"Yes"<<endl;break;}
}
if(!mark)cout<<"No"<<endl;
}
return 0;
}



内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值