|
|
вернуться в форумWhat is wrong? Way WA on test 1? Послано ss 29 мар 2005 18:07 |var t:longint; | x,i,a,b,c,len:longint; | ar:array[1..11000]of longint; | | |function simple(x:longint):boolean; |var i:integer; |begin | if x=1 then begin simple:=false; exit; end; | for i:=2 to trunc(sqrt(x))do | if x mod i =0 then begin | simple:=false; | exit | end; | simple:=true; |end; | |procedure razb(x:longint;var a,b,c:longint); |var i,j,k:longint; |begin | j:=1; | i:=1; | while (ar[i]<=x) and (i<=len) do begin | j:=i; | while (ar[j]<=x)and (j<=len) do begin | if x-ar[i]-ar[j]>=0 then | if simple(x-ar[i]-ar[j]) then begin | a:=ar[i]; | b:=ar[j]; | c:=x-ar[i]-ar[j]; | if(a=0) or(b=0) or(c=0) then begin | a:=ar[i]; | b:=ar[j]; | c:=x-ar[i]-ar[j]; | exit; | end | end; | inc(j); | end; | inc(i); | end; |end; | | |begin | t:=1; | for i:=2 to 100000 do | if simple(i) then begin | ar[t]:=i; | inc(t); | end; | len:=t; | readln(t); | for i:=1 to t do begin | readln(x); | if simple(x) then begin writeln(x); continue; end | else razb(x,a,b,c); | if a<>0 then write(a,' '); | if b<>0 then write(b,' '); | if c<>0 then writeln(c,' '); | end; |end. |
|
|