1106 Lowest Price in Supply Chain (25 point(s))

#include<cstdio>
#include<vector>
#include<iostream>
#include<cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
int mindepth = INF, maxnum;
int n, k;
double p, r;
vector<vector<int>> e;
void dfs(int u, int depth) {
	if(e[u].size() == 0) {
		if(mindepth == depth) ++maxnum; 
		if(mindepth > depth) {
			mindepth = depth;
			maxnum = 1;
		}
	}
	for(int v = 0; v < e[u].size(); ++v) dfs(e[u][v], depth + 1);
}
int main() {
	scanf("%d %lf %lf", &n, &p, &r);
	r /= 100;
	e.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &k);
		e[i].resize(k);
		for(int j = 0; j < k; ++j) scanf("%d", &e[i][j]);
	}
	dfs(0, 0);
	printf("%0.4f %d\n", p * pow(r + 1, mindepth), maxnum);
	return 0;
}

 

相关文章:

  • 2021-07-25
  • 2021-09-04
  • 2021-07-12
  • 2021-06-21
  • 2022-12-23
  • 2021-05-01
  • 2021-09-25
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2022-12-23
  • 2021-09-26
  • 2021-06-23
  • 2021-07-14
  • 2022-12-23
  • 2021-11-02
相关资源
相似解决方案