HDU 1273 orz

Source: Internet
Author: User
Walking through the forest

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 1607 accepted submission (s): 1090


Problem descriptiongardon and John enjoy walking in the forest outside the house every night. There are N open spaces in the forest, and there is a path connecting any two open spaces. Each time they depart from any blank space, they return to the original space after all the open space.
Because they like fresh trips, they do not want to go through any path twice. How many such fresh trips can they guarantee at most?
For example (figure), when n = 5, they can only keep this fresh trip twice.
The input contains multiple groups of data, each of which occupies one row and is a number n. (0 <n <= 1000000000)
The file ends at 0. Output for n of each input, the output can ensure a maximum of times of fresh travel. Sample input50 sample output2 was very difficult to look at the beginning of this question. It must involve some algorithms. After half a day, I did not come up with an algorithm that could solve this question... So I put this question there .. = When you eat, the sky shines. For the starting point, set the number of edges around it to n. If two edges are consumed for each round trip, you can go n/2 times in total, that is, n/2 fresh trips... When I think of this idea, I instantly feel a little Petrochemical... Orz code:
 1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 #include <iostream> 5 #include <vector> 6 #include <map> 7 #include <queue> 8 #include <set> 9 #include <vector>10 #include <string>11 #include <sstream>12 using namespace std;13 14 main()15 {16     int n;17     while(scanf("%d",&n)==1&&n)18     {19         printf("%d\n",(n-1)>>1);20     }21 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.