• <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 閱讀(126) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            <2009年1月>
            28293031123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(8)

            隨筆檔案

            文章檔案

            Friends

            OJ

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            精品多毛少妇人妻AV免费久久| 久久精品一本到99热免费| 色偷偷91久久综合噜噜噜噜| 少妇无套内谢久久久久| 久久久久无码精品国产| 国产成人精品久久一区二区三区av | 亚洲嫩草影院久久精品| 亚洲欧洲久久av| 国产精品伦理久久久久久| 久久天天躁狠狠躁夜夜不卡| 激情综合色综合久久综合| 色欲久久久天天天综合网| 久久亚洲国产成人精品无码区| 99久久人妻无码精品系列| 久久精品国产亚洲AV久| 久久播电影网| 国内精品久久久久久久影视麻豆| 久久免费的精品国产V∧| 久久无码国产专区精品| 亚洲欧美另类日本久久国产真实乱对白 | 久久夜色精品国产噜噜亚洲AV| 日日狠狠久久偷偷色综合免费| 99国产欧美精品久久久蜜芽| 热久久视久久精品18| 久久婷婷午色综合夜啪| 久久乐国产精品亚洲综合| 久久青青草原综合伊人| 国产精品久久久久久久久| 久久精品国产99久久无毒不卡| 日韩精品久久久肉伦网站| 午夜人妻久久久久久久久| 亚洲成色www久久网站夜月| 欧美日韩精品久久免费| 影音先锋女人AV鲁色资源网久久 | 亚洲乱码中文字幕久久孕妇黑人| 精品国产热久久久福利| 色婷婷狠狠久久综合五月| 久久久国产精品| 中文字幕久久精品无码| 99国产欧美久久久精品蜜芽| 久久伊人精品青青草原高清|