文件名称:chexiangchongzu
- 所属分类:
- Windows编程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 170kb
- 下载次数:
- 0次
- 提 供 者:
- bangban*******
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
背景
在一个旧式的火车站旁边有一座桥,其桥面可以绕河中心的桥墩水平旋转。一个车站的职工发现桥的长度最多能容纳两节车厢,如果将桥旋转180度,则可以把相邻两节车厢的位置交换,用这种方法可以重新排列车厢的顺序。
于是他就负责用这座桥将进站的车厢按车厢号从小到大排列。
他退休后,火车站决定将这一工作自动化,其中一项重要的工作是编一个程序,输入初始的车厢顺序,计算最少用多少步就能将车厢排序。
输入
输入文件有两行数据,第一行是车厢总数N(不大于100000),第二行是N个不同的数表示初始的车厢顺序。
输出
一个数据,是最少的旋转次数。-BackgroundIn an old train station next to a bridge, the bridge can rotate around the river center pier horizontal rotation. One of the stations of the workers found the length of the bridge can accommodate up to two cars, if the bridge will be rotated 180 degrees, you can put two adjacent carriage position exchange, this method can be used to rearrange the order of carriage.He is responsible for this bridge will stop the compartments are arranged from small to large carriage number.After his retirement, train station decided to bring the work of automation, one of the most important work is to write a program, enter the initial compartment sequence, computing at least how many steps can be sorting compartments.InputInput file has two lines of data, the first line is the total number of N compartment ( less than 100000 ), the second line is N different numbers of initial compartment sequence.OutputA data, is the least number of rotation.
在一个旧式的火车站旁边有一座桥,其桥面可以绕河中心的桥墩水平旋转。一个车站的职工发现桥的长度最多能容纳两节车厢,如果将桥旋转180度,则可以把相邻两节车厢的位置交换,用这种方法可以重新排列车厢的顺序。
于是他就负责用这座桥将进站的车厢按车厢号从小到大排列。
他退休后,火车站决定将这一工作自动化,其中一项重要的工作是编一个程序,输入初始的车厢顺序,计算最少用多少步就能将车厢排序。
输入
输入文件有两行数据,第一行是车厢总数N(不大于100000),第二行是N个不同的数表示初始的车厢顺序。
输出
一个数据,是最少的旋转次数。-BackgroundIn an old train station next to a bridge, the bridge can rotate around the river center pier horizontal rotation. One of the stations of the workers found the length of the bridge can accommodate up to two cars, if the bridge will be rotated 180 degrees, you can put two adjacent carriage position exchange, this method can be used to rearrange the order of carriage.He is responsible for this bridge will stop the compartments are arranged from small to large carriage number.After his retirement, train station decided to bring the work of automation, one of the most important work is to write a program, enter the initial compartment sequence, computing at least how many steps can be sorting compartments.InputInput file has two lines of data, the first line is the total number of N compartment ( less than 100000 ), the second line is N different numbers of initial compartment sequence.OutputA data, is the least number of rotation.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
车厢重组\Debug\vc60.idb
........\.....\vc60.pdb
........\.....\车厢重组.exe
........\.....\车厢重组.ilk
........\.....\车厢重组.obj
........\.....\车厢重组.pch
........\.....\车厢重组.pdb
........\车厢重组.cpp
........\车厢重组.dsp
........\车厢重组.dsw
........\车厢重组.ncb
........\车厢重组.opt
........\车厢重组.plg
........\Debug
车厢重组
........\.....\vc60.pdb
........\.....\车厢重组.exe
........\.....\车厢重组.ilk
........\.....\车厢重组.obj
........\.....\车厢重组.pch
........\.....\车厢重组.pdb
........\车厢重组.cpp
........\车厢重组.dsp
........\车厢重组.dsw
........\车厢重组.ncb
........\车厢重组.opt
........\车厢重组.plg
........\Debug
车厢重组