TouchStone
  请登录后使用
登录 注册
 系统首页  练习题库  考试列表  判题结果  信息发布  解题排行
  • 首页
  • 题库
  • 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