其他分享
首页 > 其他分享> > 1106 Lowest Price in Supply Chain (25 分)(dfs)

1106 Lowest Price in Supply Chain (25 分)(dfs)

作者:互联网

1106 Lowest Price in Supply Chain (25 分)

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
vector<int> v[100100];
int minh = 99999999, ret = 0;
void dfs(int x, int h){
	if(v[x].size() == 0){
		if(h < minh){
			minh = h;
			ret = 1;
		}
		else if(h == minh)
			ret++;
	}
	for(int i = 0; i < v[x].size(); ++i)
		dfs(v[x][i], h + 1);
}
int main(){
	int n, k, x;
	double p, r;
	cin >> n >> p >> r;
	for(int i = 0; i < n; ++i){
		cin >> k;
		while(k--){
			cin >> x;
			v[i].push_back(x);
		}
	}
	dfs(0, 0);
	printf("%.4lf %d", pow(1 + r / 100.0, minh) * p, ret);
}

标签:Lowest,25,minh,Chain,int,ret,++,dfs,include
来源: https://blog.csdn.net/weixin_46309592/article/details/121877348