|
|
вернуться в форумI need some HELP! Why Wrong Answer? This is right !!! This is my SOLUTION. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- var S, Sr1, sr2: string; i, i1, l, N, sum, sl, code, W: integer; Procedure One_summ1(var sum:integer); Begin Sum:=0; For l:=1 to length(sr1) do begin val(sr1[l],sl,code); Sum:=sum+l*Sl; end; end; Begin Readln(N); Repeat Readln(S); Val(S,W,code); If W=0 then begin for i:=1 to Length(S) do Write('0'); continue; end; If Length(s)=N+1 then begin For i1:=1 to length(S) do begin sr1:=s; Delete(sr1,i1,1); One_summ1(sum); If ((sum)mod(n+1)=0) then begin Writeln(Sr1); Break; end; end; end; If Length(s)=N then begin For i1:=1 to length(S) do begin sr1:=s; If sr1[i1]='1' then sr1[i1]:='0' else continue; One_summ1(sum); If ((sum)mod(n+1)=0) then begin Writeln(Sr1); Break; end; end; end; If Length(s)=N-1 then Begin For i1:=1 to length(S)+1 do begin sr1:=s; sr2:=s; Insert('1',sr1,i1); Insert('0',sr2,i1); One_summ1(sum); If ((sum)mod(n+1)=0) then begin Writeln(Sr1); Break; end; sr1:=sr2; One_summ1(sum); If ((sum)mod(n+1)=0) then begin Writeln(Sr1); Break; end; end; end; until EOF; End. ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- I suppose, the output is INCORRECT. PLEASE, HELP ME OR WRITE SOME TEST! Thank you. Re: I need some HELP! Why Wrong Answer? This is right !!! you shoudln't use string; because the number 'n' is >> 4<= n <=1000, but string is only 255 long. |
|
|