На языке C++ будет так:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a,b,c;
double D, x1, x2;
cout<<"Введите a"<<endl;
cin >>a;
cout<<"Введите b"<<endl;
cin >>b;
cout<<"Введите c"<<endl;
cin >>c;
if (a == 0){
cout<<"Коэффициент a не может быть равен 0"<<endl;
return 0;
}
D = b*b - 4 * a * c;
if (D >= 0){
if (D == 0){
x1 = -(double)b /(2*a);
cout<<"x = "<<x1<<endl;
}
else{
x1 = (-b + sqrt(D)) / (2*a);
x2 = (-b - sqrt(D)) / (2*a);
cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
}
}
else{
cout<<"Корней нет. D = "<<D<<endl;
}
return 0;
}
program t;
var n, i, a, b, c, d, k, m: integer; x1, x2, x3, y1, y2, y3: array[1..10000] of integer; f1, f2: text;
function icl(x, y: integer): boolean;
var i: integer;
begin
icl:=false;
for i:=1 to n do
begin
if (x>=x1[i]) and (y>=y1[i]) and (x<=x2[i]) and (y<=y2[i]) then
begin
icl:=true;
break
end
end
end;
procedure re(st, fn: integer);
var nst, nfn, i, j, jj, xx, yy: integer; eq, ff: boolean;
begin
m:=m+1;
nst:=k+1;
ff:=false;
for i:=st to fn do
begin
for j:=0 to 11 do
begin
if j mod 3=0 then continue;
xx:=x3[i]+trunc(cos(j*pi/6)*3);
yy:=y3[i]+trunc(sin(j*pi/6)*3);
if not icl(xx, yy) then continue;
eq:=false;
for jj:=1 to k do if (xx=x3[jj]) and (yy=y3[jj]) then
begin
eq:=true;
break
end;
if eq then continue;
if (xx=c) and (yy=d) then
begin
ff:=true;
break
end;
k:=k+1;
x3[k]:=xx;
y3[k]:=yy;
end;
if ff then break;
end;
if ff then exit;
nfn:=k;
if nst>nfn then
begin
m:=-1;
exit
end;
re(nst, nfn)
end;
begin
assign(f1, 'horse.in');
reset(f1);
assign(f2, 'horse.out');
rewrite(f2);
readln(f1, n);
for i:=1 to n do readln(f1, x1[i], y1[i], x2[i], y2[i]);
readln(f1, a, b);
readln(f1, c, d);
k:=1;
x3[1]:=a;
y3[1]:=b;
m:=0;
re(1, 1);
writeln(f2, m);
close(f1);
close(f2)
end.
В)16 разрядами
...