A supply chain is a network of retailers (retailer), distributors (dealer), and suppliers (supplier)--everyone involved in moving a produ CT from supplier to customer.
Starting from one root supplier, everyone on the chain buys products from one's supplier in a price P and sell or Distribu Te them in a price, is r% higher than P. Only the retailers would face the customers. It is assumed this member in the supply chain have exactly one supplier except the root supplier, and there is no supp Ly cycle.
Now given a supply chain and you is supposed to tell the lowest price a customer can expect from some retailers.
Input Specification:
Each input file contains the one test case. For each case, the first line contains three positive numbers:n (<=105), the total number of the "members" in the supply Chain (and hence their ID ' s is numbered from 0 to N-1, and the root supplier ' s ID is 0); P, the price of given by the root supplier; and r, the percentage rate of price increment for each distributor or retailer. Then N lines follow, each describes a distributor or retailer in the following format:
Ki id[1] id[2] ... Id[ki]
Where in the i-th line, Ki was the total number of distributors or retailers who receive products from supplier I, and are T Hen followed by the ID ' s of these distributors or retailers. Kj being 0 means the j-th member is a retailer. All the numbers in a line is separated by a space.
Output Specification:
For each test case, print in one line the lowest price we can expect from some retailers, accurate up to 4 decimal places, And the number of retailers that sell at the lowest price. There must be one space between the numbers. It is guaranteed, the all the prices would not exceed 1010.
Sample Input:
10 1.80 1.003 2 3 51 91 41 702 6 11 8000
Sample Output:
1.8362 2
1#include <stdio.h>2#include <vector>3#include <algorithm>4#include <math.h>5 using namespacestd;6 intans[111][111];7 8 BOOLcmpintAintb)9 {Ten returnA >b; One } A - structnode - { thevector<int>Child ; - }; - -Node tree[100100]; + - intMIN =100100; + intCNT =0; A voidDFS (intRootintLevel ) at { - if(Tree[root].child.empty ()) - { - if(Level <MIN) - { -MIN =Level ; inCNT =1; - } to Else if(Level = =MIN) +++CNT; - } the Else * { $ for(inti =0; I < tree[root].child.size (); + +i)Panax NotoginsengDFS (tree[root].child[i],level+1); - } the } + A intMain () the { + intN,num,tem; - Doublepri,rate; $scanf"%D%LF%LF",&n,&pri,&Rate ); $vector<int>VV; - for(inti =0; i < n; + +i) - { thescanf"%d",&num); - for(intK =0; K <num; + +k)Wuyi { thescanf"%d",&tem); - Tree[i].child.push_back (TEM); Wu } - } About $DFS (0,0); - -printf"%.4LF%d\n", PRI * POW ((100.0+rate)/100.0, MIN), CNT); - A return 0; +}
1106. Lowest Price in Supply Chain (25)