Cod sursa(job #110832)

Utilizator alexrusuRusu Alexandru alexrusu Data 27 noiembrie 2007 20:36:26
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.58 kb
program cifra;
var t,i:integer;
    x,y,z:double;
    s,p,j,l:byte;
    c:0..9;
    k:array[0..1,0..9] of 0..9 = ((0,1,6,3,6,5,6,7,4,9),(0,1,4,7,6,5,6,3,6,9));
    f,g:text;
begin

  assign(f,'cifra.in');
  assign(g,'cifra.out');
  reset(f);
  rewrite(g);
  readln(f,t);
  for i:=1 to t do
  begin
    readln(f,x);
    y:=int(x/10);
    if y/2 = int(y/2) then
      l:=1
    else
      l:=0;
    s:=trunc(frac((y*7)/10)*10);
    c:= trunc(frac(x/10)*10);
    for j:=0 to c do
      s := (s + k[l,j]) mod 10;
    writeln(g,s);
  end;
  close(f);
  close(g);
end.