TouchStone
  Please Login
ログイン 登録
 ホームページ  問題セット  試験一覧  提出状況  掲示板  統計情報
  • ホーム
  • 問題セット
  • P4479
  • 問題
  • P4479RXD and dividing
    制限 : 時間制限 : 3000 MS   メモリ制限 : 565536 KB
    問題説明

    入力形式

    There are several test cases, please keep reading until EOF.
    For each test case, the first line consists of 2 integer n,k, which means the number of the tree nodes , and k means the number of parts.
    The next n−1 lines consists of 2 integers, a,b,c, means a tree edge (a,b) with cost c.
    It is guaranteed that the edges would form a tree.
    There are 4 big test cases and 50 small test cases.
    small test case means n≤100.

    出力形式

    For each test case, output an integer, which means the answer.

    サンプル入力

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

    サンプル出力

    27


    ソース  2017 Multi-University Training Contest - Team 3