Hdoj-1214-Roundtable "Number of reverse order"

Source: Internet
Author: User

RoundtableTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 3671 Accepted Submission (s): 2575


Problem DESCRIPTIONHDU ACM Training team's team members often discuss their problems when they are in the summer camp. Whenever faced with a problem they could not solve, they would sit around a round table to communicate, after everyone's discussion there is generally no solution to the problem, This is only HDU ACM Training Team Special Round table, one day you can also come in to experience: "In the day during the discussion, Eddy came up with a very eccentric idea, if they in every minute, a pair of adjacent two ACM players exchange seats, So how long does it take to get the seat order opposite to the original state? (that is, for each member, the former player on his left later on his right, the player on his right is on his left side), which of course the other clever other teammates, immediately put this strange problem to solve, you know how to solve it?

Input for a given number of n (1<=n<=32767), indicates that there are n individuals, how long it takes to get a seat order opposite to the original state (reverse) for everyone, who was originally on his left and then on his right, who was on his left.

Output one row for each data, indicating the required time in minutes

Sample Input
456

Sample Output
246

Authoreddy
SOURCE Hangzhou Electric ACM Provincial Training Team Qualifying match
Recommendeddy | We have carefully selected several similar problems for you:1215 1210 1211 1249 1204

The Round table is divided into two parts, respectively, to find two parts of the reverse number, and then let the split Round table merge (that is, to add two reverse order number), n ordinal number of the reverse number is: * N (n-1)/2; So in order to make the results of the smallest number of reverse, then try to make two parts equal (that N/2, another part of N-N/2)
#include <stdio.h> int solve (int n) {return (n (n-1))/2;} int main () {int n;while (~scanf ("%d", &n)) {int d=n/2;int res=solve (d) +solve (n-d);p rintf ("%d\n", res);} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hdoj-1214-Roundtable "Number of reverse order"

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.