|
|
back to boardWA3 o_O I have two different solutions and each of them gives me WA3 :( First - naive, here it is: ----------------------------------- read(s); l:=length(s); n:=1999; if l < n then if n mod l <> 0 then A:=n mod l else A:=l else A:=n; while l <> 1 do begin delete(s,A,1); n1:=n-(l-A); dec(l); if l < n1 then if n1 mod l <> 0 then A:=n1 mod l else A:=l else A:=n1; end; case s[1] of '?': writeln('Yes'); ' ': writeln('No'); else writeln('No comments'); end; readln; end. ----------------------------------- And the next one is recursive solution inspired by Josephus problem formula: ----------------------------------- function Jo(l: longint): longint; begin if l = 1 then Jo:=0 else Jo:=(Jo(l-1)+n) mod l; end; begin read(s); l:=length(s); n:=1999; case s[Jo(l)+1] of '?': writeln('Yes'); ' ': writeln('No'); else writeln('No comments'); end; readln; end. ----------------------------------- Please, help me with some tests information or tell me about my stupid bugs :) Maybe I miss some cases? Edited by author 12.09.2011 00:58 |
|
|