Cod sursa(job #75189)

Utilizator thanhvyThanh Vy thanhvy Data 31 iulie 2007 06:26:52
Problema PScPld Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.86 kb
program SlowPalin;

const
     inp  = 'pscpld.in';
     out  = 'pscpld.out';
     maxn = 1000000;

var
   a : array[1..maxn] of char;
   i, l, n : integer;
   ans : longint;

function Check(st, ed : integer) : integer;
         begin
              while (st < ed) and (a[st] = a[ed]) do begin
                    st += 1;
                    ed -= 1;
              end;
              if (ed <= st) then Check := 1
              else Check := 0;
         end;

BEGIN
     assign(input, inp);        reset(input);
     assign(output, out);       rewrite(output);
     n := 0;
     while not EOLN do begin
           n += 1;
           read(a[n]);
     end;

     ans := 0;
     for i := 1 to n do
         for l := 1 to n - i + 1 do
             ans += Check(i, i + l - 1);

     writeln(ans);
     close(input);              close(output);
END.