简单模拟题
program matches;
const
data:array[0..9] of integer=(6,2,5,5,4,5,6,3,7,6);
var
n,i,m,i1,ans,len,k,j:integer;
a,b:array[0..10000] of integer;
begin
assign(input,'MATCHES.in');
reset(input);
assign(output,'MATCHES.out');
rewrite(output);
readln(n);
if n<13 then
begin
writeln('0');
close(input);
close(output);
halt;
end;
dec(n,4);
m:=1;
for i:=1 to (n-5) div 2 div 2 do
m:=m*10;
len:=1;
a[0]:=data[0];
b[1]:=0;
for i:=1 to m do
begin
k:=0;
i1:=i;
while i1>0 do
begin
inc(k,data[i1 mod 10]);
i1:=i1 div 10;
end;
if k<n then
begin
inc(len);
b[len]:=i;
a[i]:=k;
end;
end;
ans:=0;
for i:=1 to len do
for j:=i to len do
if (a[b[i]]+a[b[j]]<n) and (a[b[i]+b[j]]<n) and (a[b[i]]+a[b[j]]+a[b[i]+b[j]]=n) then
begin
if i=j then inc(ans)
else inc(ans,2);
end;
writeln(ans);
close(input);
close(output);
end.