Cod sursa(job #2140954)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 24 februarie 2018 00:02:57
Problema Cifra Scor 70
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.89 kb
Program p;
const sum = 4;
var s:0..10000000000000000000;
i,n,j,c,aux:integer;
t: array [0..1,0..9] of byte;
e: array [1..30000] of string;
f,g:text;
function trans(i:integer):byte;
const n = 48;
var t,l:byte;
begin
l:=length(e[i]);
t:=ord(e[i][l])-n;
if l>1 then t:=t+(ord(e[i][l-1])-n)*10;
trans:=t;
end;
begin
t[0,0]:=0;t[0,1]:=1;t[0,2]:=4;t[0,3]:=7;t[0,4]:=6;t[0,5]:=5;t[0,6]:=6;t[0,7]:=3;t[0,8]:=6;t[0,9]:=9;
t[1,0]:=0;t[1,1]:=1;t[1,2]:=6;t[1,3]:=3;t[1,4]:=6;t[1,5]:=5;t[1,6]:=6;t[1,7]:=7;t[1,8]:=4;t[1,9]:=9;
assign(f,'cifra.in');
assign(g,'cifra.out');
reset(f);
rewrite(g);
readln(f,n);
 for i:=1 to n do
  readln(f,e[i]);
for j:=1 to n do begin
 c:=trans(j);
 s:=0;
 {aux:= c div 20;
 c:= c - aux*20;
 s:=aux*sum;}
 for i:=1 to c do begin
  s:= s + t[(i div 10) mod 2,i mod 10];
  s:= s mod 10;
  end;
 writeln(g,s);
end;
close(f);
close(g);
//readln;
end.