Construction Project 2
시간 제한2초메모리 제한1024 MB
가중치 L인 간선 (u,v)를 추가했을 때 S에서 T까지 최단 거리가 K 이하가 되는 쌍의 개수를 센다.
문제
There are stations in JOI Kingdom, numbered from to . There are train lines in JOI Kingdom, numbered from to . The train line () connects station and station bi-directionally, and requires minutes for travel.
You, a minister of JOI Kingdom, decided to construct a new train line as follows.
- You choose integers and , which satisfy . You construct a new train line, which connects station and station bi-directionally, and requires minutes for travel. Note that you can choose integers such that there already be a train line connecting station and station .
After you construct a new train line, the King of JOI Kingdom becomes happy if he can move from station to station within minutes by using some train lines. Note that transit times and waiting times for train lines are not considered.
There are ways when you choose integers and , and you want to know how many of these ways make the King happy.
Write a program which, given information of stations, the train lines, and the King’s request, calculates number of ways to choose integers that make the King happy.
입력
Read the following data from the standard input.
출력
Write one line to the standard output. The output should contain number of ways to choose integers that make the King happy.
제한
- .
- .
- .
- .
- .
- ().
- ().
- ().
- Given values are all integers.