当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3570:More happiness

题目描述
As you know, poor XMM has been dreaming to go to Happyvalley for a long time. The good news is that today her mom finally agreed to take her there this weekend!
In order to make her journey in Happyvalley happier, XMM bought a map of Happyvalley to design a good plan. Happyvalley has N scenic spots which are connected by roads. XMM found that there is exactly one path between each two spots.
XMM can start her journey from arbitrary scenic spot. Several minutes are required for her to walk from one end to the other end on each road. Also, she would spend X minutes for each spot she visit. However, many reasons, such as XMM’s mood, weather condition and so on, may alter X. So there are many possible values of X.
Mom told XMM that she would stay in Happyvalley for only P minutes. Given the information of Happyvalley and the total time P minutes, also, with the time X XMM guesses she would spend in each spot, can you tell XMM the maximum number of spots she may visit? Note that each spot should be counted only once.
输入解释
The first line of the input is T (no more than 10), which stands for the number of test cases you need to solve.
On the first line of each test case, there are two numbers, N (no more than 200) and P (no more than 2000000). The following N-1 lines state the roads in the form of “a b c” which means it takes XMM c minutes to walk from spot a to spot b or from b to a (1 <= a, b <= N, 1 <= c <= 10000).
Then an integer Q (no more than 10000) in a single line is the number of all possible value X may be. Each of the following Q lines gives a possible X (no more than 10000).
输出解释
For each test case Q+1 lines are expected.
The first line is in the format of "Case x:\n", where x is the case number counted from one.
The (i+1)-th line should be the maximum number of spots XMM could get based on each possible X.
输入样例
3
3 10
1 2 2
2 3 1
3
10
2
4
6 15
1 2 2
1 3 1
2 6 3
5 3 5
3 4 3
4
1
2
3
100
4 2000000
1 2 1
1 3 1
1 4 1
1
1
输出样例
Case 1:
1
3
2
Case 2:
5
4
3
0
Case 3:
4
来自杭电HDUOJ的附加信息
Author zhymaoiing
Recommend zhouzeyong

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3570

最后修改于 2020-10-25T23:04:51+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)