April 29, Huagensen Tea Expo 2 Ningbo Tea Culture Museum (hereinafter referred to as "tea Bo Yuan"), Qingyuan teahouse (National Hundred Best Teahouse) held at the same time. Ningbo tea industry, tea culture enthusiasts, a total of more than 100
1315-crazy Tea Party
Time limit:3.000 seconds
N Participants of crazy Tea party sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required-participants to sit-reverse order (so, left neighbors would bec ome right, and Right-left). Input
The first line
Crazy Tea Party
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 7164
Accepted: 4864
Description n participants of
Input the first line is the amount of tests. Each next line contains one integer n (1
Output for each number N of participants to crazy Tea Party
D secription N participants of«crazy tea party»sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required-participants to sit-reverse order (so, left neighbors would bec ome right, and Right-left).InputThe first line is the amount of tests. Each next line contains one integer n (1 OutputFor each number n of participants to crazy
Crazy Tea Party
Time Limit: 1000MS
Memory Limit: 10000K
DescriptionN participants of InputThe first line is the amount of tests. Each next line contains one integer n (1 OutputFor each number n of participants to crazy Tea Party print on the standard out
Question Link
N people sit in a ring, and the adjacent two can exchange positions. The minimum number of exchanges leads to the opposite of the sequence.
Idea: similar to Bubble sorting, the circular sequence can be split into two sequences for bubble respectively. When N is an odd number, it is divided into n/2 and N/2 + 1, so ans = (n/2) * (N/2-1) /2 + (n/2) * (N/2 + 1)/2. When n is an even number, it is divided into two n/2, so ans = (n/2) * (N/2-1 ).
Code:
#include
Uva1315-crazy
This article mainly for you in detail the Python Basic Tutorial project Five virtual Tea Party, with a certain reference value, interested in small partners can refer to
Almost every time you learn or use any programming language, there is never a little bit of practice about sockets, especially when it comes to writing some local area network communications. So this project in the book just can practice s
ZOJ 1730 Crazy Tea Party (5418)
Test instructions: People sit around the round table and ask how many times they need to exchange a group of people at least to get everyone in the opposite order.
Idea: One pair means and can only be exchanged for two people next to each other. Bubble sort. But 1 2 3 4 5 does not need to become 5 4 3 2 1, 5 to 1 after the back, into 2 1 5 4 3, is the minimum number of time
Crazy Tea Party
Time Limit: 1000MS
Memory Limit: 10000K
Description n participants of
Input the first line is the amount of tests. Each next line contains one integer n (1
Output for each number N of participants to crazy Tea Party print on the standard output, o
Crazy tea partygrade: 10/discount: 0.8 time limit: 1000 ms memory limit: 65536 K description
N participating ants of InputThe first line is the amount of tests. Each next line contains one integer N (1
OutputFor each number n of participants to crazy Tea Party print on the standard output, on a separate line, the minimum time required for all participants to sit
Zoj 1730Crazy Tea Party (5418)
People sat around the round table and asked how many times each group of people had to be exchanged to bring the order of all people to the contrary from the beginning.
Ideas:One pairIt means that only two people can exchange positions. Bubble sorting. However1 2 3 4 5No need5 4 3 2 15Receive1After21 5 4 3Is the minimum number of times. The number of people is parity.X = N
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.