|
|
back to boardHELP !!! My program is WA, but I think this's RIGHT !!! Posted by Dim 31 Mar 2003 20:24 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 seekEOF; End. ---------------------------------------------------------------------------------------- Maybe then output is INCORRECT. PLEASE, HELP ME OR WRITE SOME TEST! Thank you. Re: HELP !!! My program is WA, but I think this's 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 seekEOF; > End. > ---------------------------------------------------------------------- ------------------ > Maybe then output is INCORRECT. > PLEASE, HELP ME OR WRITE SOME TEST! > Thank you. > Help! Help! Help! HELP !!! Posted by Dim 12 May 2003 22:22 Give me some tests or some new ideas, PLEASE !!!!! I want to solve this problem. Thanks. You have a problem with the input read: "except maybe for some extra spaces or line breaks" |
|
|