|
|
вернуться в форумwhy I got 'ACCESS_VIOLATION' Here's my program: program p1356; var fb:array[1..600000] of boolean; pn:array[1..60000] of longint; np,t,ii,n:longint; procedure init; var i,j:longint; begin np:=0; fillchar(fb,sizeof(fb),true); fb[1]:=false; for i:=2 to round(sqrt(600000)) do if not fb[i] then continue else begin inc(np); pn[np]:=i; for j:=2 to 600000 div i do fb[i*j]:=false; end; for i:=round(sqrt(600000)) to 600000 do if fb[i] then begin inc(np); pn[np]:=i; end; end; procedure main; var i,j,ij:longint; begin if fb[n] then begin writeln(n); exit; end; if not odd(n) then begin for i:=1 to np do if (pn[i]<n)and(fb[n-pn[i]]) then begin writeln(pn[i],' ',n-pn[i]); exit; end; end else begin for i:=1 to np do if pn[i]>n then break else if fb[n-pn[i]] then begin writeln(pn[i],' ',n-pn[i]); exit; end else begin for j:=1 to np do if n-pn[i]-pn[j]<0 then break else if not fb[n-pn[i]-pn[j]] then continue else begin writeln(pn[i],' ',pn[j],' ',n-pn[i]-pn[j]); exit; end; end; end; end; begin init; readln(t); if t=0 then halt; for ii:=1 to t do begin readln(n); main; end; end. Re: why I got WRONG ANSWER :) [code deleted] Edited by moderator 11.03.2006 17:04 |
|
|