why?40分

P1579 哥德巴赫猜想(升级版)

ljc20020730 @ 2016-03-15 16:07:39

var n,i,j,k:longint;
    f:boolean;
    a:array[1..2262]of longint;
procedure pring(x,y,z:longint);
var i,j,t:integer;
    b:array[1..3]of longint;
begin
 b[1]:=x;b[2]:=y;b[3]:=z;
 for i:=1 to 3 do
  for j:=i+1 to 2 do
   if b[i]>b[j] then begin t:=b[i];b[i]:=b[j];b[j]:=t;end;
 for i:=1 to 2 do write(b[i],' ');writeln(b[3]);
end;
begin
 readln(n);
 for i:=2 to 20000 do
 begin
  f:=true;
  for j:=2 to trunc(sqrt(i)) do
   if i mod j=0 then f:=false;
   if f then begin inc(k); a[k]:=i;end;
  end;
  for i:=1 to n do
   for j:=1 to n do
    for k:=1 to n do
     if a[i]+a[j]+a[k]=n then begin pring(a[i],a[j],a[k]); halt;end;
end.

|