文件名称:chexiangchongzu
介绍说明--下载内容均来自于网络,请自行研究使用
Descr iption
在一个旧式的火车站旁边有一座桥,其桥面可以绕河中心的桥墩水平旋转。一个车站的职工发现桥的长度最多能容纳两节车厢,如果将桥旋转180度,则可以把相邻两节车厢的位置交换,用这种方法可以重新排列车厢的顺序。
于是他就负责用这座桥将进站的车厢按车厢号从小到大排列。
他退休后,火车站决定将这一工作自动化,其中一项重要的工作是编一个程序,输入初始的车厢顺序,计算最少用多少步就能将车厢排序。
Input
输入文件有两行数据,第一行是车厢总数N(不大于10000),第二行是N个不同的数表示初始的车厢顺序。
Output
一个数据,是最少的旋转次数。
Sample Input
4 4 3 2 1
Sample Output
6-Descr iption in an old-fashioned train station next to a bridge deck horizontal rotation around the center of the river piers. A station workers found that the length of the bridge can accommodate up to two cars, if the bridge is rotated 180 degrees, you can exchange the position of the two compartments adjacent to, this way you can rearrange the order of the compartment. He is responsible for the compartments of the bridge will stop the car number in ascending order. After his retirement, the railway station decided to automate this work, one of the important work is to compile a program, enter the order in which the initial compartments calculated minimum number of steps will be able to sort the compartment. Input Input file has two rows of data, the first line is the compartment total number N (not more than 10000), and the second line is N different number indicates the order in which the initial carriage. Output a data, which is the minimum number of rotations. Sample Input 4 4 3 2
在一个旧式的火车站旁边有一座桥,其桥面可以绕河中心的桥墩水平旋转。一个车站的职工发现桥的长度最多能容纳两节车厢,如果将桥旋转180度,则可以把相邻两节车厢的位置交换,用这种方法可以重新排列车厢的顺序。
于是他就负责用这座桥将进站的车厢按车厢号从小到大排列。
他退休后,火车站决定将这一工作自动化,其中一项重要的工作是编一个程序,输入初始的车厢顺序,计算最少用多少步就能将车厢排序。
Input
输入文件有两行数据,第一行是车厢总数N(不大于10000),第二行是N个不同的数表示初始的车厢顺序。
Output
一个数据,是最少的旋转次数。
Sample Input
4 4 3 2 1
Sample Output
6-Descr iption in an old-fashioned train station next to a bridge deck horizontal rotation around the center of the river piers. A station workers found that the length of the bridge can accommodate up to two cars, if the bridge is rotated 180 degrees, you can exchange the position of the two compartments adjacent to, this way you can rearrange the order of the compartment. He is responsible for the compartments of the bridge will stop the car number in ascending order. After his retirement, the railway station decided to automate this work, one of the important work is to compile a program, enter the order in which the initial compartments calculated minimum number of steps will be able to sort the compartment. Input Input file has two rows of data, the first line is the compartment total number N (not more than 10000), and the second line is N different number indicates the order in which the initial carriage. Output a data, which is the minimum number of rotations. Sample Input 4 4 3 2
(系统自动生成,下载前可以参看下载内容)
下载文件列表
车厢重组\车厢重组\车厢重组.cpp
........\车厢重组
车厢重组