文件名称:chexiangchongzu
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:519byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
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
车厢重组/车厢重组
车厢重组
车厢重组/车厢重组
车厢重组
1999-2046 搜珍网 All Rights Reserved.
本站作为网络服务提供者,仅为网络服务对象提供信息存储空间,仅对用户上载内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。