作业帮 > 英语 > 作业

acm,麻烦给出具体代码或具体算法.

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/04/29 21:41:13
acm,麻烦给出具体代码或具体算法.
Description
When escaping from the Death Eater's hunting ,due to the influence of the Horcruxes ,Ron Weasley once misunderstood Harry Potter and Hermione Granger so that he left them alone .When Ron was missing Hermione ,he would always took out a pile of Hermione photos ,but he found that the photos were conjured magic by Harry and the back of the photos incredibly is Harry In order to break the magic ,Ron had to obey the rules Harry ever provided .
At first ,Ron had to put these photos sorted by Harry in a line and he had to turn over these photos to what Harry set before so that the magic would be broken .However ,every time ,when Ron turned over a photo ,its right photo will be turned over at the same time (if there is a photo at its right side).Ron wonder the least times he had taken .Harry ensures the magic could be broken .
Input
The first line is a integer T(
说说大体思路吧,具体程序自己编吧.
1. 从文件中读入这些数据.
2.就一个case来说, 用2个字符数组保存原始数据和目标.例如a[21], t[21],两个数组全部初始化为0;
3. 设i=0, step = 0;
4. 如果i=21或a[i]=0,则结束;
否则 比较a[i]与t[i],
如果相等,i=i+1; 重复步骤4;
如果不相等,翻a[i], 当然a[i+1]也要翻,step +=1;重复步骤4.
再问: 恩恩,基本方法就是这样!英语没学好,呵呵!