http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1953
这道题挺简单的,但是有陷阱啊.刚开始掉进去了,怎么也爬不出来.后来看了别人的解题报告才发现.哎..被骗了.以后注意这种题型.
题目中说:
(1) If there is an invalid move before all disks being on peg 3 and the invalid move is the p-th move of this case (start from 1) , output the integer -p please and the moves after this move(if any) are ignored.
(2) If after the p-th move all disks are on peg 3 without any invalid move, output the integer p please and the moves after this move (if any) are ignored.
结果那两个ignore被我ignore了..T_T.
我写了一个for循环,在里面输入数据.然后判断是否要停止程序然后打印结果..后来才发现如果停止了..后面输入的数据就输入到下一个测试数据组了..
然后只好将数据先放到数组里.然后判断..
上代码: