|
|
вернуться в форумSo Simple Move Back Hints: - Use 3variable which means first,too and last and - do for n downto 1 ... - use "1 shr i" to get 2^i.. - eachtime just swap 2 of (from,temp or too)... and... for i:=n downto 1 do begin if p[i]=temp then begin writeln(-1); exit; end else if p[i]=from then swap(temp,too) else begin inc(ans,(1 shl (i-1))); swap(from,temp); end; end; For more information: aidin_n7@hotmail.com Re: So Simple Move Back Послано PSV 30 ноя 2007 22:54 Yeah cool problem IMHO |
|
|