program hotrotinhoc;
const fi='NT.INP';
fo='NT.OUT';
var x,y,d,n: integer;
f: text;
function nt(a: byte): boolean;
var j: byte;
begin
nt:=true;
if (a=2) or (a=3) then exit;
nt:=false;
if (a<=0) or (a=1) or (a mod 2=0) or (a mod 3=0) then exit;
j:=6;
while (j<=trunc(sqrt(a))) do
begin
if (a mod j=0) or (x mod (j+2)=0) then exit;
j:=j+5;
end;
nt:=true;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,n);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
d:=0;
for x:=1 to n do
for y:=x to n do
if (x+y=n) and nt(x) and nt(y) then inc(d) ;
write(f,d);
close(f);
end;
begin
ip;
out;
end.
var n,x,dem:byte;
f:text;
function kt(so:byte):boolean;
var k:byte;
begin
if (so=2) or (so=3) then exit(true);
if (so=1) or (so mod 2=0) or (so mod 3=0) then exit(false);
k:=5;
repeat
if (so mod k =0) or (so mod (k+2)=0) then break;
inc(k,6);
until k>trunc(sqrt(so));
exit(k>trunc(sqrt(so)));
end;
begin
assign(f,'NT.inp');reset(f);
readln(f,n);
close(f);
assign(f,'NT.out');rewrite(f);
dem:=0;
for x:=1 to n div 2 do
if (kt(x)) and (kt(n-x)) then inc(dem);
writeln(f,dem);
close(f);
readln
end.
chúc bạn học tốt!