TouchStone
  Please Login
Login Sign Up
 Homepage  Problem Set  Examinations  Submissions  Discussions  Statistics
  • Home
  • Problem Set
  • P4479
  • Problem
  • P4479RXD and dividing
    Limits : Time Limit : 3000 MS   Memory Limit : 565536 KB
    Description

    Input Format

    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.

    Output Format

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

    Sample Input

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

    Sample Output

    27


    Source  2017 Multi-University Training Contest - Team 3