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

13762번 - Calculating Taxes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 512 MB10106100.000%

문제

The Jones family is a very wealthy family who has lived in an area of the country for many generations. In this area of the country, houses are scattered around with dirt roads connecting them. Two houses are called neighbours if there is a dirt road connecting them. Using the dirt roads, there is exactly one way to get from any house to any other house without walking on some road at least twice. There is a new king in the country and he has decided that he will be taking taxes in a rather weird way.

Each household is to pick some divisor of their income from the last year (this value could be their full income if they wish). If any neighbours pick a number whose greatest common divisor is larger than 1, then the king will take every dollar from every person in the country. On the other hand, if each pair of neighbours pick numbers whose greatest common divisor is 1, then each household may keep whatever number they chose.

Obviously, one option is for each household to take \1ドル each, but that is not very profitable. Can you help them maximize the total amount of money that they can keep?

입력

The input will contain a single test case.

The first line will contain one integer n (2 ≤ n ≤ 250) denoting the number of houses. The next n lines contain the information about each household. The first line will contain information about house 1, the second line will contain information about house 2, etc.

Each of these lines will begin with two integers, Ik (1 ≤ Ik ≤ 200 000 000) and mk (1 ≤ mk ≤ n − 1), denoting the income of the kth household and the number of neighbours of the kth household. Then follow mk distinct integers denoting the neighbours of the kth household (each will be between 1 and n, inclusive, and none of these will be k).

Each road is bidirectional and will be listed twice in the input (once for each endpoint of the road).

출력

Output one integer, the maximum total amount of money that the households can keep.

제한

예제 입력 1

4
2 1 2
3 2 1 3
2 2 2 4
3 1 3

예제 출력 1

10

예제 입력 2

4
3 1 2
9 2 1 3
3 2 2 4
9 1 3

예제 출력 2

20

예제 입력 3

6
4 3 3 4 6
3 1 3
18 3 1 2 5
6 1 1
9 1 3
10 1 1

예제 출력 3

37

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > 2015 ACM South Pacific Programming Contest C번

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

출처

대학교 대회

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

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