Logo
(追記) (追記ここまで)

10122번 - Hotels 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB35615112047.059%

문제

There are n towns in Byteotia, connected with only n-1 roads. Each road directly links two towns. All the roads have the same length and are two way. It is known that every town can be reached from every other town via a route consisting of one or more (direct-link) roads. In other words, the road network forms a tree.

Byteasar, the king of Byteotia, wants three luxury hotels erected to attract tourists from all over the world. The king desires that the hotels be in different towns and at the same distance one from each other.

Help the king out by writing a program that determines the number of possible locations of the hotel triplet in Byteotia.

입력

The first line of the standard input contains a single integer n(1 ≤ n ≤ 5,000), the number of towns in Byteotia. The towns are numbered from 1 to n.

The Byteotian road network is then described in n-1 lines. Each line contains two integers a and b (1 ≤ a ≤ b ≤ n) , separated by a single space, that indicate there is a direct road between the towns a and b.

출력

The first and only line of the standard output should contain a single integer equal to the number of possible placements of the hotels.

제한

예제 입력 1

7
1 2
5 7
2 5
2 3
5 6
4 5

예제 출력 1

5

힌트

The triplets (unordered) of towns where the hotels can be erected are: {1,3,5}, {2,4,6}, {2,4,7}, {2,6,7}, {4,6,7}.

출처

Olympiad > Polish Olympiad in Informatics > POI 2013/2014 > Stage 1 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /