• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 74,  comments - 33,  trackbacks - 0
            Perfect Service
            Time Limit: 2000MS Memory Limit: 65536K
            Total Submissions: 661 Accepted: 319

            Description

            A network is composed of N computers connected by N ? 1 communication links such that any two computers can be communicated via a unique route. Two computers are said to be adjacent if there is a communication link between them. The neighbors of a computer is the set of computers which are adjacent to it. In order to quickly access and retrieve large amounts of information, we need to select some computers acting as servers to provide resources to their neighbors. Note that a server can serve all its neighbors. A set of servers in the network forms a perfect service if every client (non-server) is served by exactly one server. The problem is to find a minimum number of servers which forms a perfect service, and we call this number perfect service number.

            We assume that N (≤ 10000) is a positive integer and these N computers are numbered from 1 to N. For example, Figure 1 illustrates a network comprised of six computers, where black nodes represent servers and white nodes represent clients. In Figure 1(a), servers 3 and 5 do not form a perfect service because client 4 is adjacent to both servers 3 and 5 and thus it is served by two servers which contradicts the assumption. Conversely, servers 3 and 4 form a perfect service as shown in Figure 1(b). This set also has the minimum cardinality. Therefore, the perfect service number of this example equals two.

            Your task is to write a program to compute the perfect service number.

            Input

            The input consists of a number of test cases. The format of each test case is as follows: The first line contains one positive integer, N, which represents the number of computers in the network. The next N ? 1 lines contain all of the communication links and one line for each link. Each line is represented by two positive integers separated by a single space. Finally, a 0 at the (N + 1)th line indicates the end of the first test case.

            The next test case starts after the previous ending symbol 0. A ?1 indicates the end of the whole inputs.

            Output

            The output contains one line for each test case. Each line contains a positive integer, which is
            the perfect service number.

            Sample Input

            6
            1 3
            2 3
            3 4
            4 5
            4 6
            0
            2
            1 2
            -1

            Sample Output

            2
            1
            樹的最小支配集:和3659一樣。TreeDP求解:
            代碼同上篇隨筆一樣:
            posted on 2009-04-09 22:58 KNIGHT 閱讀(116) 評論(0)  編輯 收藏 引用
            <2009年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            99久久人妻无码精品系列蜜桃| 777午夜精品久久av蜜臀| 狠狠久久综合伊人不卡| 99久久免费只有精品国产| 久久免费视频网站| 国产成人久久精品一区二区三区| 精品熟女少妇AV免费久久| 7777久久久国产精品消防器材| 一本一本久久a久久综合精品蜜桃| 亚洲欧美日韩精品久久亚洲区| 色婷婷综合久久久中文字幕| 久久夜色精品国产亚洲av| 人人狠狠综合久久亚洲88| 精品一久久香蕉国产线看播放| 久久99热这里只有精品国产| 久久国产亚洲精品| 欧美黑人又粗又大久久久| 久久妇女高潮几次MBA| 999久久久无码国产精品| 免费精品国产日韩热久久| 精品久久777| 久久精品九九亚洲精品| 伊人久久大香线蕉亚洲五月天| 久久精品18| 久久久久久久久久久免费精品| 99国产精品久久久久久久成人热| 久久精品国产亚洲av麻豆图片| 久久婷婷五月综合成人D啪| 国产午夜精品久久久久九九| 久久国产成人精品麻豆| 国产精品久久久久久福利漫画| 久久国产色AV免费看| 国内精品久久久久影院日本| 久久久无码精品亚洲日韩按摩 | 久久精品国产亚洲av麻豆蜜芽| 久久AⅤ人妻少妇嫩草影院| 久久99精品久久久久久噜噜| 99久久国产主播综合精品| 青青青青久久精品国产h| 国产精品久久久久久久午夜片 | 亚洲国产成人久久精品99 |