旅游

旅游
Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format:  %lld      Java class name:  Main  Submit Statute  Statistics  Discuss  Next
Font Size:  +   -
Type:  NoneGraph Theory     2-SAT    Articulation/Bridge/Biconnected Component     Cycles/Topological Sorting/Strongly Connected Component     Shortest Path         Bellman Ford        Dijkstra/Floyd Warshall     Euler Trail/Circuit     Heavy-Light Decomposition     Minimum Spanning Tree     Stable Marriage Problem     Trees     Directed Minimum Spanning Tree     Flow/Matching        Graph Matching             Bipartite Matching             Hopcroft–Karp Bipartite Matching             Weighted Bipartite Matching/Hungarian Algorithm         Flow             Max Flow/Min Cut             Min Cost Max Flow DFS-like    Backtracking with Pruning/Branch and Bound     Basic Recursion     IDA* Search    Parsing/Grammar     Breadth First Search/Depth First Search     Advanced Search Techniques         Binary Search/Bisection         Ternary Search Geometry     Basic Geometry    Computational Geometry     Convex Hull     Pick's TheoremGame Theory     Green Hackenbush/Colon Principle/Fusion Principle     Nim     Sprague-Grundy Number Matrix    Gaussian Elimination     Matrix Exponentiation Data Structures     Basic Data Structures     Binary Indexed Tree     Binary Search Tree     Hashing    Orthogonal Range Search     Range Minimum Query/Lowest Common Ancestor     Segment Tree/Interval Tree     Trie Tree     Sorting    Disjoint Set String     Aho Corasick    Knuth-Morris-Pratt     Suffix Array/Suffix Tree Math     Basic Math    Big Integer Arithmetic     Number Theory         Chinese Remainder Theorem         Extended Euclid         Inclusion/Exclusion         Modular Arithmetic     Combinatorics        Group Theory/Burnside's lemma         Counting     Probability/Expected Value Others    Tricky     Hardest    Unusual     Brute Force     Implementation    Constructive Algorithms     Two Pointer     Bitmask    Beginner     Discrete Logarithm/Shank's Baby-step Giant-step Algorithm     Greedy     Divide and Conquer Dynamic Programming     Tag it!

 

某L是一个旅游爱好者,并且伴有轻微强迫症。不管去什么地方旅游,他总是要走遍每一个景点,以求不留遗憾。

 前段时间,他又去了一个名叫YNBHX的景区,这个景区非常特别,它一共有N个景点和N-1条小道,每条小道连接这N个景点中的某两个,并保证从景区内每一个景点都能通过若干条小道到达另一个景点。

由于景区人数微多,景区规定,每人每天可以选择任意一个景点出发到达另一个景点,但途中不能走回头路(即每一条小道在同一天之内只能经过一次),现在某L想知道,对于这个神奇的景区,他要想游览完所有的景区至少需要几天?=,=

Input

 

第一行一个整数N,表示共有N个景点。(N<=1000)

接下来N-1行,每行两个整数A、B,表示景点A和景点B之间有一条小道。

Output

一个整数K,表示某L要想游览完所有景点至少需要K天。

Sample Input

Sample Input1
3
1 2
2 3

Sample Input2
4
1 2
1 3
1 4

Sample Output

 
   
Sample Output1 1 Sample Output2 2
水题:只用判断无向图的度,度大于2的把大于2的部分加起来,最后ans=(sum+1)/2+1;
 
#include 
#include 
int in[2000]={0};
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x,y;
        for(int i=1;i2)
            {
                ans+=(in[i]-2);
            }
        }
        printf("%d\n",(ans+1)/2+1);
    }
    return 0;
}


 
  

你可能感兴趣的:(旅游)