10917 - Walk Through the Forest翻譯

Problem C: A Walk Through the Forest
Jimmy experiences a lot of stress at work these days, especially since his accident made working difficult.
漫步森林
Jimmy這些天工作感覺很壓力,尤其以後他的事故使工作困難
To relax after a hard day, he likes to walk home.
辛苦工作一天後去放鬆,他想走路回家
To make things even nicer, his office is on one side of a forest, and his house is on the other.
使事情更好,他的辦公室在森林的一側,他的房子在另一側
A nice walk through the forest, seeing the birds and chipmunks is quite enjoyable.
通過森林散步很好,看鳥和花栗鼠很愉快
The forest is beautiful, and Jimmy wants to take a different route everyday. He also wants to get home before dark, so he always takes a path to make progress towards his house.
森林很美麗,Jimmy想走不同的路線每天。他想天黑前回家,所以他總是選一條路朝着他的房子前進
He considers taking a path from A to B to be progress if there exists a route from B to his home that is shorter than any possible route from A.
他認爲選一個路徑A到B前進,從B到他的家比從A到他的家任何路線都短
Calculate how many different routes through the forest Jimmy might take.
計算Jimmy有多少種不同路線通過森林
Input
Input contains several test cases followed by a line containing 0.
輸入包含若干測試數據,以下一行爲0
Jimmy has numbered each intersection or joining of paths starting with 1.
Jimmy從編號1開始
His office is numbered 1, and his house is numbered 2.
他的辦公室是編號1,他的房子是編號2
The first line of each test case gives the number of intersections N, 1 < N ≤ 1000, and the number of paths M. The following M lines each contain a pair of intersections a b and an integer distance 1 ≤ d ≤ 1000000 indicating a path of length d between intersection a and a different intersection b.
第一行測試數據給一個交點數字N,1<N<=1000,路徑M。以下M行包含一對交點 a b 一個整數距離1 ≤ d ≤ 1000000代表a和b路徑長度d(a≠b)
Jimmy may walk a path any direction he chooses. There is at most one path between any pair of intersections.
Jimmy可以選不同的路選擇。最少一條路在一對交點
Output
For each test case, output a single integer indicating the number of different routes through the forest. You may assume that this number does not exceed 2147483647.
每組測試案例。輸出一組整數代表不同路徑通過森林。輸入保證答案不超過2147483647(2的31次-1)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章