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

whi i get always CM! PLEASE HELP ME AND I WILL TEL YOU SENC HERE IS A MY PROGRAM
Posted by I am david. Tabo. 24 Apr 2002 17:28
Var N   : Integer;
    C   : Array[0..1500] of Char;
    A   : Array[0..1500] of Integer;
    S   : Array[1..10] of String[255];
 Total  : Longint;

Procedure Main(X : Integer);
Var i,j : Longint;
Begin
  If XN then
    Begin
      For i := 1 to N+1 do
        If (Total-(A[X]-A[i])-(A[i]-A[i-1])*i) Mod (N+1)=0
then
          Begin
            For j := 1 to i-1 do
              Write(C[j]);
            For j := i+1 to X do
              Write(C[j]);
            Writeln;
            Exit;
          End;
    End;
  If X=N then
    Begin
      If Total Mod (N+1)=0 then
        Begin
          For j := 1 to N do
            Write(C[j]);
          Writeln;
          Exit;
        End;
      For i := 1 to X do
        If C[i]='1' then
          If (Total-i) Mod (N+1)=0 then
            Begin
              C[i] := '0';
              For j := 1 to X do
                Write(C[j]);
              Writeln;
              Exit;
            End;
    End;
End;


Procedure Init;
Var i,j,k,l : Longint;
    BB      : Boolean;
    Long    : Byte;
Begin
  Readln(N);
  Long := (N+1) Div 255;
  If (N+1) mod 255<>0 then Inc(Long);
  Repeat
    Fillchar(S,Sizeof(S),0);
    For i := 1 to Long do
      Read(S[i]);
    If Pos('0',S[1])=0 then
      If Pos('1',S[1])=0 then Break;
    Readln;
    j := 0;
    Fillchar(A,Sizeof(A),0); Total := 0;
    For i := 1 to Long do
      For k := 1 to Length(S[i]) do
        Begin
          If S[i][k] in ['0','1'] then
            Begin
              Inc(j);
              A[j] := A[j-1]+Ord(S[i][k])-48;
              Inc(Total,(Ord(S[i][k])-48)*j);
              C[j] := S[i][k];
            End;
        End;
    Main(j);
  Until Eof;
End;

Begin
  Init;
End.
Re: whi i get always CM! PLEASE HELP ME AND I WILL TEL YOU SENC HERE IS A MY PROGRAM
Posted by minkerui 25 Apr 2002 21:20
Maybe you choose the wrong language.