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

HELP !!! 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 !!!
Posted by Egroman 1 Apr 2003 17:59
> 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
Posted by Sergeyev Alexander 9 Sep 2003 15:57
read: "except maybe for some extra spaces or line breaks"