zoj 2954 Hanoi Tower

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循环,在里面输入数据.然后判断是否要停止程序然后打印结果..后来才发现如果停止了..后面输入的数据就输入到下一个测试数据组了..

然后只好将数据先放到数组里.然后判断..

上代码:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值