在网上找到一个很好的算法,仔细观察可以发现,目标序列的开头几个乌龟都是经过移动后形成的,只要从原始序列中对比查找目标序列是否相同就能很快得到答案 ,代码够短了吧,呵呵 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=103&page=show_problem&problem=1093 首先找到需要移动的字符串,方法如下:以初始序列为准,设初始序列下标为i, 目的序列下标为j, 从n-1开始,如果两下标对应的字符串相等,下标同时减一,否则仅初始序列 Read More
posted @ 2012-08-15 22:38
godjob
Views(239)
Comments(0)
Diggs(0)
找规律1: 12 1 13 1 1 14: 1 2 1 5 1 2 1 16 1 2 2 17 1 2 2 1 18 1 2 2 2 19: 1 2 3 2 110 1 2 3 2 1 111 1 2 3 2 2 112 1 2 3 3 2 113 1 2 3 3 2 1 114 1 2 3 3 2 2 115 1 2 3 3 3 2 116: 1 2 3 4 3 2 1n*n:2*n-1N*N-(N-1)*(N-1)-12*n-2因为完全平方数的最小step是确定的所以,以完全平方数为界限。n*n: 1......n......1 minstep:2*n-1..n*(n+1) 1...... Read More
posted @ 2012-08-15 17:17
godjob
Views(149)
Comments(0)
Diggs(0)

浙公网安备 33010602011771号