|
|
back to boardWhat's the algorithm to this problem? Posted by Li Yi 7 Oct 2001 13:54 Re: What's the algorithm to this problem? > This is a my solution: Suppose: m<=n if m=1 then sol:=(n+1) div 2 else begin if (m mod 3=0)or(n mod 3=0) then sol:=2 else sol:=1; end; How did you realise this algorithm? How did you realise this algorithm? How can you proof that? This solution really impressed me! :-) You may e-mail me: fortuna@acm.org Thank you > > This is a my solution: > Suppose: m<=n > if m=1 then sol:=(n+1) div 2 else > begin > if (m mod 3=0)or(n mod 3=0) then sol:=2 else sol:=1; > end; > Why after m and n mod 3, The situation havn't change? and the result either 1 or 2 ? Posted by aaakkk 3 Mar 2002 07:55 > > > > This is a my solution: > > Suppose: m<=n > > if m=1 then sol:=(n+1) div 2 else > > begin > > if (m mod 3=0)or(n mod 3=0) then sol:=2 else sol:=1; > > end; > > |
|
|