ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1007. Code Words

I need some HELP! Why Wrong Answer? This is right !!!
Posted by Duplyakin 8 Apr 2003 18:19
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 !!!
Posted by geniushjs 15 Aug 2003 08:21
you shoudln't use string; because the number 'n' is >> 4<= n <=1000,
but string is only 255 long.