22195_Pair

2022-5-16 18:21| 发布者: Hocassian| 查看: 27| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506191317700-Problem List-采集的数据-后羿采集器.html

Pro.ID

22195

Title

Pair

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22195

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    There are n cities in country X. Some pairs of cities are connected by bidirectional roads, and there exists one and only one path between every pair of cities.

    Lily wants to take a trip in country X. She can start from any city, and she wouldn't visit a city twice. Lily is effeminate, so the total distance of this trip should not be larger than L.

    Your task is to calculate the number of all possible trips. Two trips are distinct if and only if the set of cities they contain are different.

    输入

    The first line contains two integers n and m, n is the number of cities, and m is the number of roads. The following m lines describe m roads, each of which contains three integers a, b, c, representing that a and b are connected by an undirected road which length is c. The last line contains an integer L.

    1 ≤ n ≤ 100000, 1 ≤ c ≤ 10000, 1 ≤ L ≤ 1000000000.

    输出

    Description

    There are n cities in country X. Some pairs of cities are connected by bidirectional roads, and there exists one and only one path between every pair of cities.

    Lily wants to take a trip in country X. She can start from any city, and she wouldn't visit a city twice. Lily is effeminate, so the total distance of this trip should not be larger than L.

    Your task is to calculate the number of all possible trips. Two trips are distinct if and only if the set of cities they contain are different.

    Input

    The first line contains two integers n and m, n is the number of cities, and m is the number of roads. The following m lines describe m roads, each of which contains three integers a, b, c, representing that a and b are connected by an undirected road which length is c. The last line contains an integer L.

    1 ≤ n ≤ 100000, 1 ≤ c ≤ 10000, 1 ≤ L ≤ 1000000000.

    Output

    For each case, output a line contains a integer.

    Sample Input

    3 2
    2 3 10
    1 3 10
    15
    4 3
    2 3 10
    1 3 5
    3 4 3
    14

    Sample Output

    5
    9

    Source

    样例输入

    3 2
    2 3 10
    1 3 10
    15
    4 3
    2 3 10
    1 3 5
    3 4 3
    14

    样例输出

    5
    9

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部