Cod sursa(job #407858)

Utilizator lsorin_94Lodoaba Sorin lsorin_94 Data 2 martie 2010 18:06:24
Problema Ecuatie Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.79 kb
program num5;
const r=1;
type vec=array [1..1000000] of word;
var i,j,n:word;
    st,s0:word;
    k,s,min,an,a1,max:word;
    sfi:real;
    a:vec;
    f,t:text;
begin
  assign(f,'numere5.in');
  reset(f);
  assign(t,'numere5.out');
  rewrite(t);
  read(f,n);
  n:=n*n;
  for i:=1 to n do
    read(f,a[i]);
  {-----------------------}
  k:=0;s:=0;min:=maxint;max:=0;
  for i:=1 to n do
    begin
     if a[i]<>0 then if a[i]<min then min:=a[i];
     if a[i]<>0 then if a[i]>max then max:=a[i];
     if a[i]=0 then k:=k+1
       else S:=s+a[i];
    end;
  a1:=1;
  an:=a1+(n-1)*r;
  st:=((a1+an)*n) div 2;
  S0:=St-S;
  sfi:=S0*2/k;
  a1:=trunc(trunc(sfi-k-1) div 2);
  an:=a1+r*(k-1);
  {-----------------------}
  write(t,a1,' ',an+1);
  close(f);
  close(t);
end.